-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostcss.config.js
More file actions
68 lines (65 loc) · 1.7 KB
/
postcss.config.js
File metadata and controls
68 lines (65 loc) · 1.7 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
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
let config = require("./project.config.js");
const cssImport = require("postcss-import");
const cssAssets = require("postcss-assets");
const cssNext = require("postcss-cssnext");
const cssNested = require("postcss-nested");
const cssNano = require("cssnano");
const cssMqPacker = require("css-mqpacker");
const cssInlineSvg = require("postcss-inline-svg");
const cssSprite = require("postcss-sprites");
// console.log(config.src);
let postcssConfig = {
plugins: [
cssImport({
root: config.root.toString(),
path: [
// node_modules exists in resolve paths by default and we don't need to place it here
config.components,
config.src,
config.css.dir
]
}),
cssNested(),
cssNext({
features: {
nesting: false
}
}),
cssAssets({
basePath: config.src,
loadPaths: [config.img.dir]
}),
cssInlineSvg({
path: config.src,
removeFill: true
}),
cssMqPacker({
sort: true
}),
cssSprite({
stylesheetPath: config.css.dist,
spritePath: config.img.dist,
basePath: config.src,
spritesmith: {
padding: 2
},
// eslint-disable-next-line
verbose: config.isDevelopment ? false : true,
filterBy: function(image) {
if (image.url.indexOf("/sprites/") === -1) {
return Promise.reject(new Error("Not in sprite folder."));
}
return Promise.resolve();
}
})
]
};
if (!config.isDevelopment) {
postcssConfig.plugins.push(
cssNano({
safe: true,
autoprefixer: false //autoprefixer in cssNano works in delete mode, while in cssNext in add mode. Disable delete mode.
})
);
}
module.exports = postcssConfig;