refactor: add friendly-errors-webpack-plugin in both client and server

This commit is contained in:
Clark Du 2018-03-19 22:47:39 +08:00
parent e116ff5a71
commit 010064fcf0
No known key found for this signature in database
GPG Key ID: D0E5986AF78B86D9
2 changed files with 10 additions and 10 deletions

View File

@ -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)
}

View File

@ -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',