-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
40 lines (32 loc) · 921 Bytes
/
index.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
38
39
40
var postcss = require('postcss');
var P = {
autoprefixer: require('autoprefixer'),
cssnext: require('cssnext')()
};
var def = {
cssnext: false,
autoprefixer: false,
customPlugin: function () {}
};
module.exports = function (content, file, conf) {
if (file.isCssLike) {
var opts = fis.util.merge(def, conf);
var plugins = [];
if (opts.cssnext) {
plugins.push(P.cssnext);
opts.autoprefixer = false; // cssnext 自带 autoprefixer
}
if (opts.autoprefixer) {
plugins.push(P.autoprefixer);
}
var tmp = opts.customPlugin.call(this, plugins, content, file, conf);
if (Array.isArray(tmp) && tmp.length) {
plugins = tmp;
}
if (!plugins.length) {
return content;
}
content = postcss(plugins).process(content).css;
}
return content;
};