-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpostcss.config.js
More file actions
59 lines (56 loc) · 1.77 KB
/
postcss.config.js
File metadata and controls
59 lines (56 loc) · 1.77 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
const config = require('./project.config');
const cssImport = require('postcss-import');
const cssAssets = require('postcss-assets');
const cssNext = require('postcss-cssnext');
const cssNano = require('cssnano');
const cssMqPacker = require('css-mqpacker');
const cssInlineSvg = require('postcss-inline-svg');
const cssReporter = require('postcss-reporter');
const cssSprite = require('postcss-sprites');
let postcssConfig = {
//just comment: in webpack we should sent object with field plugins and array of plugins, but in gulp we should send only array, not object
plugins: [
cssImport({
root: config.root,
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
]
}),
cssNext,
cssAssets({
basePath: config.src,
loadPaths: [config.img.dir]
}),
cssInlineSvg({ path: config.src }),
cssMqPacker({
sort: true
}),
cssReporter({
throwError:true
}),
cssSprite({
stylesheetPath : config.css.dist,
spritePath: config.img.dist,
basePath: config.src,
spritesmith: {
padding: 5
},
verbose: config.isVerbose,
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;