optimize-css-assets-webpack-plugin icon indicating copy to clipboard operation
optimize-css-assets-webpack-plugin copied to clipboard

Discard code comment in css

Open ngohungphuc opened this issue 7 years ago • 5 comments

In my webpack config file. I'm using this config

new OptimizeCSSAssetsPlugin({
                cssProcessorOptions: {
                    safe: true,
                    discardComments: {
                        removeAll: true,
                    },
                },
            })

When run webpack command I'm still see those command in css file. Any idea ?

code_2018-11-14_17-02-47

ngohungphuc avatar Nov 14 '18 10:11 ngohungphuc

I have the following and it works:

new OptimizeCssAssetsPlugin({
  cssProcessorPluginOptions: {
      preset: ['default', { discardComments: { removeAll: true } }],
  }
});

The settings are for the default cssnano processor rather than the optimize plugin.

johnhunter avatar Dec 21 '18 14:12 johnhunter

@ngohungphuc I'm having the same problem. Did you find a solution for this? Changin options to

{
      preset: ['default', { discardComments: { removeAll: true } }],
}

didn't work for me

ghost avatar Jul 25 '19 14:07 ghost

Still working for me. My full plugin config is:

new OptimizeCssAssetsPlugin({
  cssProcessorPluginOptions: {
      assetNameRegExp: /\.css$/g,
      preset: ['default', { discardComments: { removeAll: true } }],
  }
});

Plugin version i'm using is currently 5.0.3

johnhunter avatar Jul 25 '19 14:07 johnhunter

My full code is here https://github.com/SaiGonSoftware/Awesome-CMS-Core/blob/master/src/AwesomeCMSCore/AwesomeCMSCore/webpack.config.js

Currently working fine now

ngohungphuc avatar Jul 25 '19 15:07 ngohungphuc

Mine works now but only because I put the config into a separate cssnano.config.js file. If I put it in the plugin directly it still doesn't work but I'm cool with having it work in a separate file.

ghost avatar Jul 28 '19 00:07 ghost