forked from FullHuman/purgecss
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpurgecss.js
More file actions
30 lines (30 loc) · 845 Bytes
/
Copy pathpurgecss.js
File metadata and controls
30 lines (30 loc) · 845 Bytes
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
"use strict";
var t,
e = require("purgecss"),
s = (t = e) && "object" == typeof t && "default" in t ? t.default : t;
function i(t, e = []) {
return e.filter(
(e) =>
!!t.file.exists(e) || (t.log.warn(`Source file "${e}" not found.`), !1)
);
}
module.exports = function (t) {
t.registerMultiTask("purgecss", "Grunt plugin for PurgeCSS", function () {
const n = this.async(),
o = this.options(e.defaultOptions);
for (const e of this.files) {
const r = i(t, e.src);
new s()
.purge({ ...o, css: r })
.then((s) => {
if (void 0 === e.dest) throw new Error("Destination file not found");
t.file.write(e.dest, s[0].css),
t.log.writeln(`File "${e.dest}" created.`),
n();
})
.catch(() => {
n(!1);
});
}
});
};