From e116ff5a7110f6ede0f6f0747023f4dbb49da98b Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 19 Mar 2018 22:41:16 +0800 Subject: [PATCH 1/2] fix: extractCSS:true and dev:false break building --- lib/builder/webpack/client.config.js | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/lib/builder/webpack/client.config.js b/lib/builder/webpack/client.config.js index c9002a8c48..442f1a5d35 100644 --- a/lib/builder/webpack/client.config.js +++ b/lib/builder/webpack/client.config.js @@ -130,7 +130,9 @@ module.exports = function webpackClientConfig() { // CSS extraction const extractCSS = this.options.build.extractCSS - if (extractCSS) { + // TODO: Temporary disabled in dev mode for fixing source maps + // (We need `source-map` devtool for *.css modules) + if (extractCSS && !this.options.dev) { config.plugins.push(new ExtractTextPlugin(Object.assign({ filename: this.getFileName('css') From 010064fcf0ec6d1548fc71813de3f6a76fd8a9bc Mon Sep 17 00:00:00 2001 From: Clark Du Date: Mon, 19 Mar 2018 22:47:39 +0800 Subject: [PATCH 2/2] refactor: add friendly-errors-webpack-plugin in both client and server --- lib/builder/webpack/base.config.js | 10 ++++++++++ lib/builder/webpack/client.config.js | 10 ---------- 2 files changed, 10 insertions(+), 10 deletions(-) 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',