Created
May 27, 2020 20:27
-
-
Save c10r/7253f8f64902c406a60389f3129e37a6 to your computer and use it in GitHub Desktop.
Enable purgeCSS in webpack
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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