error message:
ERROR UglifyJs keyword «const»
{
test: /\.js$/,
loader:'babel-loader',
//exclude: /node_modules/, //After commenting, es5 conversion will be performed first, and then packaged and compressed
}
This change has her reason, because: UglifyJsPlugin cannot compress es6 code, and some npm packages of es6 may be referenced in the project.
But: it may cause a new error! ! !
TypeError: $export is not a function
How to solve this error? If you look for a solution, you will find such an answer
{
test: /\.js$/,
loader: 'babel-loader',
exclude: /node_modules/, // Need to add this line
}
The uglify-es
used by uglifyjs-webpack-plugin
is no longer maintained and replaced by a branch called terser. Therefore, webpack officially abandoned the use of uglifyjs-webpack-plugin
, it is recommended to use terser-webpack-plugin
.