Feat: add possiblity to mute webpack in non-dev modes (#2411)

Move webpackStats to nuxt.options

Only clearConsole when we expect webpack to output stats
This commit is contained in:
Pim 2017-12-17 14:59:50 +01:00 committed by Pooya Parsa
parent 0f4bf0f9b2
commit c92d427bb0
3 changed files with 17 additions and 13 deletions

View File

@ -39,17 +39,7 @@ module.exports = class Builder {
this.customFilesWatcher = null
// Mute stats on dev
this.webpackStats = this.options.dev ? false : {
chunks: false,
children: false,
modules: false,
colors: true,
excludeAssets: [
/.map$/,
/index\..+\.html$/,
/vue-ssr-client-manifest.json/
]
}
this.webpackStats = this.options.dev ? false : this.options.build.stats
// Helper to resolve build paths
this.relativeToBuild = (...args) => relativeTo(this.options.buildDir, ...args)

View File

@ -106,8 +106,11 @@ module.exports = function webpackClientConfig() {
}))
}
const shouldClearConsole = this.options.build.stats !== false &&
this.options.build.stats !== 'errors-only'
// Add friendly error plugin
config.plugins.push(new FriendlyErrorsWebpackPlugin())
config.plugins.push(new FriendlyErrorsWebpackPlugin({ clearConsole: shouldClearConsole }))
// --------------------------------------
// Dev specific config

View File

@ -228,7 +228,18 @@ Options.defaults = {
templates: [],
watch: [],
devMiddleware: {},
hotMiddleware: {}
hotMiddleware: {},
stats: {
chunks: false,
children: false,
modules: false,
colors: true,
excludeAssets: [
/.map$/,
/index\..+\.html$/,
/vue-ssr-client-manifest.json/
]
}
},
generate: {
dir: 'dist',