我的配置中有以下内容:
const viewerConfigProdWeb = merge(common.commonWebConfig, {
output: {
path: outputPath,
filename: common.bundleNameWeb
},
devtool: 'source-map',
mode: 'production',
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
uglifyOptions: {
compress: false, //<--- if enabled, causes errors
ecma: 6,
mangle: true,
exclude: path.resolve(__dirname, '../js/vendor/tomtom.min.js'), // <--- it is already minified, want to exclude it somehow. But this approach doesn't work =(
}
})
]
}
});
当我在 uglifyOptions 中将 'compress' 更改为 true 时,出现运行时错误。当 webpack 尝试优化已经压缩和缩小的第三方库时,就会出现这些错误。如何将其排除在优化之外?
更新:根据 Sin 的回答和自述文件,将配置中的优化部分更改为以下内容:
optimization: {
minimizer: [
new UglifyJsPlugin({
cache: true,
parallel: true,
sourceMap: true,
exclude: /\.min\.js$/, //<---- moved up and used regex
uglifyOptions: {
compress: true, //<---- still causes errors when enabled
ecma: 6,
mangle: true
}
})
]
}
这也不起作用=(还有其他想法吗?