Purgecss: How to properly use multiple whitelist patterns?

Created on 21 Apr 2020  路  3Comments  路  Source: FullHuman/purgecss

I'd like PurgeCSS to ignore specific classes, as I have noticed that styles for specific external scripts are gone.

This seems to work:

    whitelist: ['vfl-label-on-input', 'vfl-has-label', 'vfl-label', 'label']

However, I have tried doing like so:

    whitelistPatterns: [/viewer$/, /vfl$/]

I'd like to whitelist "viewer" and "viewer-canvas" as well as "vfl-has-label", etc.

But that does not work.

Not sure what I am doing wrong

All 3 comments

How does this work on the cli line?

I tried

purgecss --css csscache/st__blue_.css  --output csspurified/ --content '[index.php, something.php]' --whitelist border_blue, border_green

and

purgecss --css csscache/st__blue_.css  --output csspurified/ --content '[index.php, something.php]' --whitelist '[border_blue, border_green]'

but the class .border_blue and green are gone

@simplenotezy whitelistPatterns is using regular expression to match the selectors you want to ignore.
You can try your regular expression on a website like RegExr.
/viewer$/ will not whitelist viewer-canvas because it will match selectors ending with viewer.
/vfl$/ will whitelist selectors ending with vfl

@rubo77 whitelist should be comma separated -- whitelist border_blue,border_green
I would recommend using a configuration file when the configuration is _complicated_. It will be easier:

purgecss --config ./purgecss.config.js
Was this page helpful?
0 / 5 - 0 ratings

Related issues

Ffloriel picture Ffloriel  路  6Comments

crazy4groovy picture crazy4groovy  路  7Comments

TomS- picture TomS-  路  3Comments

knowler picture knowler  路  3Comments

TylerBarnes picture TylerBarnes  路  5Comments