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.
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.
Patterns are regular expressions. You can use regexr to verify the regular expressions correspond to what you are looking for.
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.