Anyone have a working uglify-js webpack configuration?

I’m using React with webpack, and now trying a production configuration that includes uglification, comment stripping to start.

My webpack.config.js module.exports includes

  optimization: {
    minimizer: [
      new UglifyJsPlugin({
        uglifyOptions: {
          output: {
            comments: false,
          },
        },
      }),
    ],
  },

but using that with webpack --mode production (it’s ignored for --mode development) just gets me some obscure error

ERROR in main.js from UglifyJs
Unexpected token: name «texts», expected: punc «;» [main.js:1273,6]
error Command failed with exit code 2.

I’m a bit lost in this big webpack world, clearly, and anyone with a working uglification configuration would be helpful to hear from.

Eventually, I’d like to turn on name mangling, etc., to protect intellectual property, etc.

Anyone? Bueller, Bueller? :wink:

It was working for us with a simple configuration:

  optimization: {
    minimizer: [
      new UglifyJsPlugin(),
    ]
  },

but I recently had to move away from UglifyJS, because it does not support es6, so it would die with an exception on the first const keyword it encountered.

Thanks for that. Yes, over on the AdobeDev Slack, I was pointed to Terser, which looks like the current winner (an evolution from UglifyJS).