What to do if purgeCSS is purging code inside an ignore block

Last updated on December 20, 2021

After hours of wondering why my CSS was still being purged even though it was inside /* purge start ignore */ and /* purgecss end ignore /*, I discovered a simple answer on Github that I wanted to share.

Add ! so your ignore comments look like this:

1
/*! purgecss start ignore */
2
/*! purgecss end ignore */

This removes any comments in and around rules, selectors & declarations. But comments marked with ! are kept by default.

Enjoy purging!

Invite us to your inbox.

Articles, guides and interviews about web development and career progression.

Max 1-2x times per month.