1、报错情况
All browser targets in the browserslist configuration have supported ES module.
Therefore we don't build two separate bundles for differential loading.
✔ Building for production...
ERROR ValidationError: Invalid options object. Terser Plugin has been initialized using an options object
that does not match the API schema.
- options has an unknown property 'sourceMap'. These properties are valid:
object { test?, include?, exclude?, terserOptions?, extractComments?, parallel?, minify? }
ValidationError: Invalid options object. Terser Plugin has been initialized using an options object that does not match the API schema.
- options has an unknown property 'sourceMap'. These properties are valid:
object { test?, include?, exclude?, terserOptions?, extractComments?, parallel?, minify? }
....
2、原因:
造成上面问题的原因是terser-webpack-plugin版本问题。
3、解决方案:
推荐使用terser-webpack-plugin@4.2.3。更新版本,重新打包即可。
npm install terser-webpack-plugin@4.2.3
在尝试构建生产环境时遇到报错,问题根源在于terser-webpack-plugin版本不兼容。解决方案是降级到terser-webpack-plugin@4.2.3版本,并重新执行打包操作,以消除因源码映射(sourceMap)属性导致的API匹配错误。
1万+

被折叠的 条评论
为什么被折叠?



