Skip to content

Instantly share code, notes, and snippets.

@anova
Last active January 11, 2024 17:35
Show Gist options
  • Save anova/313fc451e3385ebc794feaced6111a74 to your computer and use it in GitHub Desktop.
Save anova/313fc451e3385ebc794feaced6111a74 to your computer and use it in GitHub Desktop.
const { PurgeCSSPlugin } = require("purgecss-webpack-plugin");
const glob = require("glob-all");
// https://stackoverflow.com/a/77249323/181295
module.exports = {
plugins: [
new PurgeCSSPlugin({
defaultExtractor: (content) => {
const defaultSelectors = content.match(/[A-Za-z0-9_-]+/g) || [];
const extendedSelectors = content.match(/[^<>"=\s]+/g) || [];
return defaultSelectors.concat(extendedSelectors);
},
paths: glob.sync([
'./**/*.html',
],{
nodir: true
}),
safelist: {
standard: [],
keyframes: [],
deep: [],
greedy: [],
}
}),
],
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment