Skip to content

Documentation for PurgeCSS out of date #1047

Description

@kurtome

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"]
    }
  ]
}

Activity

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

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions