ERROR in static/js/10.1253c0b3f1b4afab1655.js from UglifyJs TypeError: "name.definition is not a function"
I got the following error when building for production. This is in a project that is using NPM webpack to build artifacts for a production server. The project is also using the UglifyJSPlugin in the following way:
const UglifyJSPlugin = require('uglifyjs-webpack-plugin')
minimizer: [
new UglifyJSPlugin({
uglifyOptions: {
compress: {
warnings: false
}
},
sourceMap: config.build.productionSourceMap,
parallel: true
}),
CodePudding user response:
If uglifyjs-webpack-plugin is an old version, like 1.1.1, upgrade; in my case, to to 2.2.0, the latest version.
npm install uglifyjs-webpack-plugin@latest
The following change is also necessary, moving the warnings false outside of the compress block for the new version.
new UglifyJSPlugin({
uglifyOptions: {
warnings: false
},
sourceMap: config.build.productionSourceMap,
parallel: true
})
This resolved my problem.