-
Notifications
You must be signed in to change notification settings - Fork 59
/
Copy pathpostcss.config.cjs
30 lines (29 loc) · 1.29 KB
/
postcss.config.cjs
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
const autoprefixer = require('autoprefixer');
const pxtorem = require('postcss-pxtorem');
module.exports = {
plugins: [
autoprefixer(),
pxtorem({
rootValue({ file }) {
// 特别注意:如果用vant官网示例 `file.indexOf('vant')` 来匹配,请确保你的项目名或文件名没有包含'vant'
// 建议改为 `file.indexOf('node_modules/vant')`
return file.indexOf('node_modules/vant') !== -1 ? 37.5 : 75;
},
unitPrecision: 5,
propList: ['*'],
selectorBlackList: ['.ignore', 'keep-px'],
minPixelValue: 1,
/**
* 注意:这里mediaQuery仅仅设置是否转换media选择器本身的px,而不是该选择器下style的px
* 如: @media screen and (min-width: 768px) { html: { font-size: 76.8px } }
* mediaQuery: true => @media screen and (min-width: 10.24rem) { html: { font-size: 1.024rem } }
* mediaQuery: false => @media screen and (min-width: 768px) { html: { font-size: 1.024rem } }
* 解决:
* 1. 使用'PX'忽略转换单个属性(注意prettier会将'PX'格式化为'px', 需使用'/* prettier-ignore *\/'忽略格式化)
* 2. 使用exclude忽略整个文件
*/
mediaQuery: false,
// exclude: (file) => /response\.less/i.test(file),
}),
],
};