-
Notifications
You must be signed in to change notification settings - Fork 2
/
purifycss.js
37 lines (32 loc) · 1002 Bytes
/
purifycss.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
let path = require('path');
let fs = require('fs');
// https://github.com/purifycss/purifycss
let purifycss = require('purify-css');
function fromDir(startPath, filter, callback) {
if (!fs.existsSync(startPath)) {
console.log('no dir ', startPath);
return;
}
const files = fs.readdirSync(startPath);
for (let i = 0; i < files.length; i++) {
const filename = path.join(startPath, files[i]);
const stat = fs.lstatSync(filename);
if (stat.isDirectory()) {
fromDir(filename, filter, callback); // recurse
} else if (filter.test(filename)) {
callback(filename);
}
}
}
fromDir('./dist/frontend/browser', /^.*theme-(?!.*(default)).*css$/, function (filename) {
const content = ['./dist/frontend/browser/*.js', './dist/frontend/browser/*.html'];
const css = [filename];
const options = {
output: filename,
minify: false,
info: true,
rejected: true,
};
console.log('-- found: ', filename);
purifycss(content, css, options);
});