代码里如果用到const 关键字,编译报这种错误

webpack 编译时,提示 Unexpected token: keyword «const»

 

 解决方法:

npm install terser-webpack-plugin --save

然后,webpack配置:
 const TerserPlugin = require('terser-webpack-plugin');
 module.exports = {
  optimization: {
    minimize: true,
    minimizer: [new TerserPlugin()],
  },
};

 

 

相关文章:

  • 2021-10-29
  • 2022-12-23
  • 2021-10-23
  • 2022-12-23
  • 2021-05-11
  • 2022-12-23
  • 2022-12-23
  • 2022-12-23
猜你喜欢
  • 2021-10-26
  • 2022-12-23
  • 2021-05-22
  • 2021-09-22
  • 2022-02-16
  • 2022-12-23
  • 2022-12-23
相关资源
相似解决方案