-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathindex.js
More file actions
38 lines (36 loc) · 1.05 KB
/
index.js
File metadata and controls
38 lines (36 loc) · 1.05 KB
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
38
const purifyCss = require('purify-css');
module.exports = function(rawCss) {
var includedFiles = '',
purifyCssOptions = {
minify: true,
info: true,
};
if (typeof this.query == 'object') {
if (this.query.includes) {
includedFiles = this.query.includes;
} else {
console.warn(
'Purify-Css: no files provided, be sure to pass a array of files that respect the glob pattern through options.includes.'
);
}
if (this.query.purifyCssOptions)
purifyCssOptions = this.query.purifyCssOptions;
} else {
console.warn(
'\nPurify-Css: no files provided, be sure to pass a array of files that respect the glob pattern through options.includes.'
);
}
this.cacheable && this.cacheable();
const cond =
typeof this.query.when === 'boolean'
? this.query.when
: process.env.NODE_ENV === 'production';
if (cond) {
const minifiedPurifiedCss = purifyCss(
includedFiles,
rawCss,
purifyCssOptions
);
return minifiedPurifiedCss;
} else return rawCss;
};