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

Documentation for PurgeCSS out of date #1047

Closed
kurtome opened this issue Jul 25, 2019 · 2 comments
Closed

Documentation for PurgeCSS out of date #1047

kurtome opened this issue Jul 25, 2019 · 2 comments

Comments

@kurtome
Copy link

kurtome commented Jul 25, 2019

The recommended configuration for using PurgeCSS does not appear to work with the latest
version of PurgeCSS.

Currently it the docs recommend:

// postcss.config.js
const purgecss = require('@fullhuman/postcss-purgecss')({

  // Specify the paths to all of the template files in your project 
  content: [
    './src/**/*.html',
    './src/**/*.vue',
    './src/**/*.jsx',
    // etc.
  ],

  // Include any special characters you're using in this regular expression
  defaultExtractor: content => content.match(/[A-Za-z0-9-_:/]+/g) || []
})

But it should use the extractor config recommended here in
the current docs,
it should look like:

// postcss.config.js
const purgecss = require('@fullhuman/postcss-purgecss')({

  // Specify the paths to all of the template files in your project 
  content: [
    './src/**/*.html',
    './src/**/*.vue',
    './src/**/*.jsx',
    // etc.
  ],

  // Include any special characters you're using in this regular expression
  extractors: [
    {
      extractor: class PurgeExtractor {
        static extract(content) {
          // return array of css selectors
          return content.match(/[A-Za-z0-9-_:/]+/g) || []
        }
      },
      extensions: ["html", "vue", "jsx"]
    }
  ]
}
@adamwathan
Copy link
Member

Definitely works, the approach in our docs is just undocumented in the Purgecss docs because it's so new:

FullHuman/purgecss#183

@kurtome
Copy link
Author

kurtome commented Jul 25, 2019

Ugh, I was using postcss-purgecss instead of @fullhuman/postcss-purgecss, sometimes I hate NPM :)

Thanks!

@kurtome kurtome closed this as completed Jul 25, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants