diff --git a/lib/builder/webpack/base.config.js b/lib/builder/webpack/base.config.js index 9f6736bec0..04bce1752e 100644 --- a/lib/builder/webpack/base.config.js +++ b/lib/builder/webpack/base.config.js @@ -1,6 +1,7 @@ const TimeFixPlugin = require('time-fix-plugin') const WarnFixPlugin = require('./plugins/warnfix') const ProgressPlugin = require('./plugins/progress') +const FriendlyErrorsWebpackPlugin = require('@nuxtjs/friendly-errors-webpack-plugin') const webpack = require('webpack') const { cloneDeep } = require('lodash') @@ -144,6 +145,15 @@ module.exports = function webpackBaseConfig({ name, isServer }) { // Hide warnings about plugins without a default export (#1179) config.plugins.push(new WarnFixPlugin()) + const shouldClearConsole = + this.options.build.stats !== false && + this.options.build.stats !== 'errors-only' + + // Add friendly error plugin + config.plugins.push( + new FriendlyErrorsWebpackPlugin({ clearConsole: shouldClearConsole }) + ) + // Clone deep avoid leaking config between Client and Server return cloneDeep(config) } diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index 442f1a5d35..c61d88bd3a 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -3,7 +3,6 @@ const webpack = require('webpack') // const VueSSRClientPlugin = require('vue-server-renderer/client-plugin') const VueSSRClientPlugin = require('./plugins/vue/client') const HTMLPlugin = require('html-webpack-plugin') -const FriendlyErrorsWebpackPlugin = require('@nuxtjs/friendly-errors-webpack-plugin') const StylishPlugin = require('webpack-stylish') const { BundleAnalyzerPlugin } = require('webpack-bundle-analyzer') const { resolve } = require('path') @@ -76,15 +75,6 @@ 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({ clearConsole: shouldClearConsole }) - ) - // Optimization config.optimization.splitChunks = { chunks: 'all',