mirror of
https://github.com/nuxt/nuxt.git
synced 2024-11-11 08:33:53 +00:00
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:
parent
cff76965f6
commit
5280e86dfc
@ -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
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user