forked from sword-Lz/project_2025
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostcss.config.js
44 lines (44 loc) · 1.3 KB
/
postcss.config.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
41
42
43
44
module.exports = {
plugins: {
autoprefixer: {},
'postcss-sprites': {
basePath: './dist',
spritePath: './dist/img/sprites',
retina: true,
filterBy: function (image) {
// Allow only png files
if (image.url.includes('sprites')) {
if (!/\.png$/.test(image.url)) {
return Promise.reject(new Error(' Allow only png files'))
}
return Promise.resolve()
}
return Promise.reject(new Error(' Allow only png files'))
},
groupBy: function (image) {
const spritesPaths = image.url.split('sprites')
if (spritesPaths.length > 1) {
const spriteImagePaths = spritesPaths[1].split('/')
if (spriteImagePaths.length > 2) {
const groupName = spriteImagePaths[1]
return Promise.resolve(groupName)
} else {
return Promise.reject(new Error('Not a group name.'))
}
} else {
return Promise.reject(new Error('Not a group name.'))
}
}
}
// 'postcss-px-to-viewport': {
// viewportWidth: 1920,
// viewportHeight: 938,
// unitPrecision: 5,
// viewportUnit: 'vw',
// selectorBlackList: [],
// minPixelValue: 1,
// mediaQuery: false,
// propList: ['*']
// }
}
}