From a3a8c0c9db577bf8e277bd95f6e6926753e666a9 Mon Sep 17 00:00:00 2001 From: Clark Du Date: Thu, 16 Aug 2018 22:35:38 +0100 Subject: [PATCH] refactor: move UglifyJs after extend for getting updated devtool (#3748) --- lib/builder/webpack/client.js | 44 +++++++++++++++++++---------------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/lib/builder/webpack/client.js b/lib/builder/webpack/client.js index d45cc39d4c..43d4c93b53 100644 --- a/lib/builder/webpack/client.js +++ b/lib/builder/webpack/client.js @@ -75,6 +75,30 @@ export default class WebpackClientConfig extends WebpackBaseConfig { return plugins } + customize() { + const config = super.customize(...arguments) + // Make uglifyjs faster + if (!this.options.dev && !config.optimization.minimizer) { + // https://github.com/webpack-contrib/uglifyjs-webpack-plugin + config.optimization.minimizer = [ + new UglifyJsWebpackPlugin({ + parallel: true, + cache: this.options.build.cache, + sourceMap: config.devtool && /source-?map/.test(config.devtool), + extractComments: { + filename: 'LICENSES' + }, + uglifyOptions: { + output: { + comments: /^\**!|@preserve|@license|@cc_on/ + } + } + }) + ] + } + return config + } + config() { const config = super.config() @@ -119,26 +143,6 @@ export default class WebpackClientConfig extends WebpackBaseConfig { ) } - // Make uglifyjs faster - if (!this.options.dev && !config.optimization.minimizer) { - // https://github.com/webpack-contrib/uglifyjs-webpack-plugin - config.optimization.minimizer = [ - new UglifyJsWebpackPlugin({ - parallel: true, - cache: this.options.build.cache, - sourceMap: config.devtool && /source-?map/.test(config.devtool), - extractComments: { - filename: 'LICENSES' - }, - uglifyOptions: { - output: { - comments: /^\**!|@preserve|@license|@cc_on/ - } - } - }) - ] - } - return this.customize(config) } }