Skip to content

Instantly share code, notes, and snippets.

@c10r
Created May 27, 2020 20:27
Show Gist options
  • Select an option

  • Save c10r/7253f8f64902c406a60389f3129e37a6 to your computer and use it in GitHub Desktop.

Select an option

Save c10r/7253f8f64902c406a60389f3129e37a6 to your computer and use it in GitHub Desktop.
Enable purgeCSS in webpack
const purgecss = require('@fullhuman/postcss-purgecss')({
// Specify the paths to all of the template files in your project
content: [
'./src/**/*.html',
'./src/**/*.js',
],
// Used to extract class names from your templates
defaultExtractor: content => {
// Capture as liberally as possible
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || []
// Capture classes within other delimiters
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || []
return broadMatches.concat(innerMatches)
}
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment