optimize-css-assets-webpack-plugin
optimize-css-assets-webpack-plugin copied to clipboard
Discard code comment in css
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 ?

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.
@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
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
My full code is here https://github.com/SaiGonSoftware/Awesome-CMS-Core/blob/master/src/AwesomeCMSCore/AwesomeCMSCore/webpack.config.js
Currently working fine now
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.