Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Using terser webpack plugin how to avoid building with comments

I am using the terser webpack plugin. I tried with this configuration.

optimization: {
    minimize: true,
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          output: {
            comments: false,
          },
        },
      }),
    ],

But still, it outputs a .LICENSE file. How to build the code without comments.

like image 249
Sumit Sarkar Avatar asked Jan 25 '26 03:01

Sumit Sarkar


2 Answers

Should be

new TerserPlugin({
    extractComments: false,
})

see https://github.com/webpack-contrib/terser-webpack-plugin#extractcomments

like image 191
tao Avatar answered Jan 28 '26 19:01

tao


The docs also give an example for "if you avoid building with comments":

module.exports = {
  optimization: {
    minimize: true,
    minimizer: [
      new TerserPlugin({
        terserOptions: {
          format: {
            comments: false,
          },
        },
        extractComments: false,
      }),
    ],
  },
};

Note: Both the extractComments: false and terserOptions: { format: { comments: false } } options are used.

like image 42
dmoz Avatar answered Jan 28 '26 20:01

dmoz



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!