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

When I specify extractors, I want to specify only the extractors I want to override #148

Closed
ahus1 opened this issue Oct 20, 2018 · 1 comment

Comments

@ahus1
Copy link
Contributor

ahus1 commented Oct 20, 2018

Describe the current behavior

When specifying an extractor specific for one file type, but no extractor for the other file types in the project, I get an exception "Cannot read property 'extractor' of undefined"

To Reproduce

  1. use html and js as content
  2. add an extractor for html, but not js
  3. run purgecss
  4. see error

Expected behavior

I want the default extract to be used for any file type that I don't specify. Apparently this happened to other people previously as well: #95

Desktop (please complete the following information):

  • OS: Windows (but shouldn't be related)
  • Version of Purgecss: 1.1.0

Additional context

Suggested fix: in getFileExtractor() the DefaultExtractor should be returned when extractorObj is undefined

purgecss/src/index.js

Lines 230 to 237 in 9b637bd

getFileExtractor(filename: string, extractors: Array<ExtractorsObj> = []) {
if (!extractors.length) return DefaultExtractor
const extractorObj: any = extractors.find(extractor =>
extractor.extensions.find(ext => filename.endsWith(ext))
)
return extractorObj.extractor
}

@Ffloriel
Copy link
Member

Yes, it would definitely be better if you can specify only the extractors I want to override.
Aiming at changing this for the next release.

bseber added a commit to focus-shift/urlaubsverwaltung-landingpage that referenced this issue Mar 9, 2019
* like ".w-1/6" which is ignored and purged by default
* currently we have to define all filetypes used in our project due to
  missing DefaultExtractor fallback by purgecss
  (FullHuman/purgecss#148)
Ffloriel added a commit that referenced this issue Apr 5, 2019
@Ffloriel Ffloriel closed this as completed Apr 5, 2019
ahus1 added a commit to ahus1/purgecss that referenced this issue Apr 12, 2019
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

2 participants