Created
March 10, 2021 02:50
-
-
Save KonnorRogers/f364b913d2ffb4ba21c6d18e15799cff to your computer and use it in GitHub Desktop.
purgecss for rails
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')({ | |
content: [ | |
'./app/**/*.html.erb', | |
'./app/helpers/**/*.rb', | |
'./app/javascript/**/*.js', | |
], | |
defaultExtractor: content => { | |
const broadMatches = content.match(/[^<>"'`\s]*[^<>"'`\s:]/g) || [] | |
const innerMatches = content.match(/[^<>"'`\s.()]*[^<>"'`\s.():]/g) || [] | |
return broadMatches.concat(innerMatches) | |
} | |
}) | |
module.exports = { | |
plugins: [ | |
require('postcss-import'), | |
require('postcss-flexbugs-fixes'), | |
require('postcss-preset-env')({ | |
autoprefixer: { | |
flexbox: 'no-2009' | |
}, | |
stage: 3 | |
}), | |
...process.env.NODE_ENV === 'production' | |
? [purgecss] | |
: [] | |
] | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment