A small project I started make use a node module (installed via npm) that declares const
variables. Running and testing this project is well, b
As ChrisR mentionned, UglifyJS does not support ES6 at all.
You need to use terser-webpack-plugin for ES6 (webpack@5 will use this plugin for uglification)
npm install terser-webpack-plugin --save-dev
Then define in your plugins
array
const TerserPlugin = require('terser-webpack-plugin')
new TerserPlugin({
parallel: true,
terserOptions: {
ecma: 6,
},
}),
Source