postcss-pxtorem 是一个postcss插件,用于将 css转换成rem。配合 js代码监测屏幕宽度,自动修改html font-size 实现自适应布局。
可是这个 postcss-pxtorem 有一些bug,在 vite 2.x下 exclude,include 等属性有问题,会导致莫名其妙的一些文件不被转换。只能不用这些选项了。
我常用的配置如下
{
rootValue: 16,
unitPrecision: 5,
mediaQuery: false,
minPixelValue: 2,
propList: [
'font*',
'*background*',
'*padding*',
'*margin*',
'letter-spacing',
'*width',
'*height',
'left',
'right',
'top',
'bottom'
]
}