Whitelisting
You can whitelist selectors to stop PurgeCSS from removing them from your CSS. This can be accomplished with the PurgeCSS options whitelist
and whitelistPatterns
, or directly in your CSS with a special comment.
Specific selectors
You can whitelist selectors with whitelist
.
In the example, the selectors .random
, #yep
, button
will be left in the final CSS.
Patterns
You can whitelist selectors based on a regular expression with whitelistPatterns
and whitelistPatternsChildren
.
In the example, selectors ending with red
such as .bg-red
, and children of selectors ending with blue
such as blue p
or .bg-blue .child-of-bg
, will be left in the final CSS.
In the CSS directly
You can whitelist directly in your CSS with a special comment. Use /* purgecss ignore */
to whitelist the next rule.
Use /* purgecss ignore current */
to whitelist the current rule.
You can use /* purgecss start ignore */
and /* purgecss end ignore */
to whitelist a range of rules.
Last updated