在我的应用程序中运行npm run build
时,会收到以下警告:static/js/widget.js contains invalid source map
。
当我在Webpack配置中删除UglifyJs设置时,构建过程将顺利进行,而不会发出任何警告。
我的Webpack配置(仅与源映射有关的部分):
// Source maps are resource heavy and can cause out of memory issue for large source files.
const shouldUseSourceMap = process.env.GENERATE_SOURCEMAP !== 'false';
module.exports = {
// Don't attempt to continue if there are any errors.
bail: true,
mode: 'production',
// We generate sourcemaps in production. This is slow but gives good results.
// You can exclude the *.map files from the build during deployment.
devtool: shouldUseSourceMap ? 'source-map' : false,
...
plugins: [
new UglifyJsPlugin({
uglifyOptions: {
sourceMap: shouldUseSourceMap,
warnings: false,
compress: {
comparisons: false
},
output: {
comments: false,
ascii_only: true
},
}
}),
]