From c92d427bb077038cf89440595f62818a4a968f4f Mon Sep 17 00:00:00 2001 From: Pim Date: Sun, 17 Dec 2017 14:59:50 +0100 Subject: [PATCH] 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 --- lib/builder/builder.js | 12 +----------- lib/builder/webpack/client.config.js | 5 ++++- lib/common/options.js | 13 ++++++++++++- 3 files changed, 17 insertions(+), 13 deletions(-) diff --git a/lib/builder/builder.js b/lib/builder/builder.js index 3b244dd1f0..832b5fd0a4 100644 --- a/lib/builder/builder.js +++ b/lib/builder/builder.js @@ -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) diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 88c815e22d..6d975b73c4 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -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 diff --git a/lib/common/options.js b/lib/common/options.js index 27e3df7dfa..f1433ec302 100755 --- a/lib/common/options.js +++ b/lib/common/options.js @@ -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',