Skip to content

Commit d52ae23

Browse files
committed
feat: add @fullhuman/postcss-purgecss
1 parent e65f2ce commit d52ae23

File tree

3 files changed

+130
-0
lines changed

3 files changed

+130
-0
lines changed

package-lock.json

Lines changed: 100 additions & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
"devDependencies": {
2020
"@babel/core": "^7.12.16",
2121
"@babel/eslint-parser": "^7.12.16",
22+
"@fullhuman/postcss-purgecss": "^4.1.3",
2223
"@pattern-lab/cli": "^5.16.2",
2324
"@pattern-lab/core": "^5.16.2",
2425
"@pattern-lab/engine-twig-php": "^5.16.2",

postcss.config.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
/* eslint-disable import/no-extraneous-dependencies */
2+
const purgecss = require('@fullhuman/postcss-purgecss');
3+
const autoprefixer = require('autoprefixer');
4+
5+
module.exports = {
6+
plugins: [
7+
autoprefixer,
8+
purgecss({
9+
content: ['./public/**/*.html', './src/**/*.vue', './source/**/*.twig'],
10+
defaultExtractor(content) {
11+
const contentWithoutStyleBlocks = content.replace(
12+
/<style[^]+?<\/style>/gi,
13+
'',
14+
);
15+
return (
16+
contentWithoutStyleBlocks.match(
17+
/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g,
18+
) || []
19+
);
20+
},
21+
safelist: [
22+
/-(leave|enter|appear)(|-(to|from|active))$/,
23+
/^(?!(|.*?:)cursor-move).+-move$/,
24+
/^router-link(|-exact)-active$/,
25+
/data-v-.*/,
26+
],
27+
}),
28+
],
29+
};

0 commit comments

Comments
 (0)