refactor: move UglifyJs after extend for getting updated devtool (#3748)

This commit is contained in:
Clark Du 2018-08-16 22:35:38 +01:00 committed by GitHub
parent 673a38216f
commit a3a8c0c9db
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -75,6 +75,30 @@ export default class WebpackClientConfig extends WebpackBaseConfig {
return plugins 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() { config() {
const config = super.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) return this.customize(config)
} }
} }