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
Logo

前往低代码交流专区

更多推荐