Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Discard code comment in css #86

Open
ngohungphuc opened this issue Nov 14, 2018 · 5 comments
Open

Discard code comment in css #86

ngohungphuc opened this issue Nov 14, 2018 · 5 comments

Comments

@ngohungphuc
Copy link

ngohungphuc commented Nov 14, 2018

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

@johnhunter
Copy link

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.

@ghost
Copy link

ghost commented Jul 25, 2019

@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

@johnhunter
Copy link

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

@ngohungphuc
Copy link
Author

@ghost
Copy link

ghost commented Jul 28, 2019

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants