Laravel Elixir Remove CSS Comments

Have you ever wanted to strip those block comments out of your production CSS? In the past, I’ve run into issues where the CSS is not processed correctly because everything gets bumped onto the same line as Bootstrap’s block comment and it somehow things it is also commented out. No worries though if you are using Laravel Elixir (or really just the cssnano plugin):

Here is an example of how you can configure cssnano to strip all comments:

If you are just using cssnano in a non-elixir build, you can still pass the discardComments: { removeAll: true }  option to achieve the same effect.

Leave a Reply

Your email address will not be published. Required fields are marked *