PostCss

.postcssrc.js

1
2
3
4
5
6
7
8
9
10
11
module.exports = {
plugins: {
/* 插件配置 */
'postcss-pxtorem': {
/* lib-flexible 的 rem 适配方案 */
rootValue: 37.5,
/* 需要转换的 css 属性 */
propList: ['*']
}
}
}

rootValue 支持两种类型

  • 数字
  • 函数
1
2
3
rootValue({ file }) {
return file.indexOf('vant') !== -1 ? 37.5 : 75
},