generate source map for uglify if devtool === #source-map (#3451)

* generate source map for uglify if devtool === #source-map

* support different variants of source-map option

* change source map to be likes in official webpack repo
https://github.com/webpack/webpack/blob/master/lib/WebpackOptionsDefaulter.js#L294

* small code cleanup
This commit is contained in:
Dmitry Molotkov 2018-07-24 14:01:51 +03:00 committed by Sébastien Chopin
parent cff76965f6
commit 5280e86dfc

View File

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