webpack 编译时,提示 Unexpected token: keyword «const»
代码里如果用到const 关键字,编译报这种错误
解决方法:
npm install terser-webpack-plugin --save
然后,webpack配置:
const TerserPlugin = require('terser-webpack-plugin'); module.exports = { optimization: { minimize: true, minimizer: [new TerserPlugin()], }, };