Skip to content

Commit 2a7a219

Browse files
committed
🔧 Configure PostCSS plugin PurgeCSS
1 parent cadec3c commit 2a7a219

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

‎postcss.config.cjs

+32
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,32 @@
1+
// eslint-disable-next-line @typescript-eslint/no-var-requires
2+
const purgecss = require('@fullhuman/postcss-purgecss');
3+
4+
5+
/**
6+
* See Vue guide for extractor and safelist
7+
* https://purgecss.com/guides/vue.html#usage
8+
*
9+
*/
10+
module.exports = {
11+
plugins: [
12+
purgecss({
13+
content: ['./src/**/*.{vue,js,ts,css,scss,html}'],
14+
extractors: [
15+
{
16+
extractor(content) {
17+
const contentWithoutStyleBlocks = content.replace(/<style[^]+?<\/style>/gi, '');
18+
return contentWithoutStyleBlocks.match(/[A-Za-z0-9-_/:]*[A-Za-z0-9-_/]+/g) || [];
19+
},
20+
extensions: ['vue']
21+
}
22+
],
23+
safelist: [
24+
/-(leave|enter|appear)(|-(to|from|active))$/,
25+
/^(?!(|.*?:)cursor-move).+-move$/,
26+
/^router-link(|-exact)-active$/,
27+
/data-v-.*/,
28+
/data-bs.*/, // Bootstrap 5 javascript data attributes
29+
],
30+
})
31+
]
32+
};

0 commit comments

Comments
 (0)