Skip to content

Commit 6196519

Browse files
committed
purgecss: use postcss plugin instead of webpack
1 parent 0cb4308 commit 6196519

File tree

4 files changed

+26
-24
lines changed

4 files changed

+26
-24
lines changed

generator/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ module.exports = (api, options) => {
33
postcss: {
44
plugins: {
55
tailwindcss: './tailwind.config.js',
6+
'vue-cli-plugin-tailwind/purgecss': {},
67
},
78
},
89
};

package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55
"author": "Jens Eggerstedt <j.eggerstedt@kaibatech.de>",
66
"license": "MIT",
77
"dependencies": {
8-
"glob-all": "^3.1.0",
9-
"purgecss-webpack-plugin": "^1.3.0",
8+
"@fullhuman/postcss-purgecss": "^1.0.1",
109
"tailwindcss": "^0.6.5"
1110
},
1211
"repository": {

purgecss/index.js

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
const isHotReloaded = process.argv.includes('serve');
2+
const postcss = require('postcss');
3+
4+
class TailwindExtractor {
5+
static extract(content) {
6+
return content.match(/[A-Za-z0-9-_:\/]+/g) || [];
7+
}
8+
}
9+
10+
let config = {
11+
content: ['./public/index.html', './src/**/*.vue'],
12+
extractors: [
13+
{
14+
extractor: TailwindExtractor,
15+
extensions: ['html', 'vue'],
16+
},
17+
],
18+
};
19+
20+
module.exports = postcss.plugin('tailwind-purgecss', function(opts) {
21+
if (isHotReloaded) return () => {};
22+
const purgecss = require('@fullhuman/postcss-purgecss');
23+
return purgecss(Object.assign(config, opts));
24+
});

webpack/index.js

Lines changed: 0 additions & 22 deletions
This file was deleted.

0 commit comments

Comments
 (0)