Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add blacklist option #302

Closed
bangzek opened this issue Mar 10, 2020 · 3 comments
Closed

Add blacklist option #302

bangzek opened this issue Mar 10, 2020 · 3 comments

Comments

@bangzek
Copy link

bangzek commented Mar 10, 2020

Writing the right extractor is hard and sometime you can over specify the selector.

Can we add blacklist that force to remove certain selector even when the extractor pull it?

@makenosound
Copy link

makenosound commented Apr 20, 2020

I’d be interested in this feature too so that I can explicitly remove a bunch of (library generated) classes that I know should be filtered out. The existing configuration options make this sort of use-case fairly convoluted (and potentially error prone).

@adamwathan
Copy link
Contributor

You can use the extractor to manually do this in the mean time:

purgecss({
  defaultExtractor: content => {
    const blacklist = [
      'class-i-dont-want',
      'another-class-i-dont-want',
    ]

    return (content.match(/[\w-/.:]+(?<!:)/g) || []).filter(match => !blacklist.includes(match))
  }
})

@Ffloriel
Copy link
Member

Progress tracked in #439

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants