diff --git a/lib/builder/webpack/client.js b/lib/builder/webpack/client.js index c5867c363d..d2271f5289 100644 --- a/lib/builder/webpack/client.js +++ b/lib/builder/webpack/client.js @@ -98,26 +98,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: false, - extractComments: { - filename: 'LICENSES' - }, - uglifyOptions: { - output: { - comments: /^\**!|@preserve|@license|@cc_on/ - } - } - }) - ] - } - // Add HMR support if (this.options.dev) { config.entry = [ @@ -153,6 +133,26 @@ 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 config } }