在项目根目录下创建 postcss.config.cjs 文件,并配置如下内容:
module.exports = ({ webpack }) => {
return {
plugins: {
autoprefixer: {
overrideBrowserslist: [
"Android 4.1",
"iOS 7.1",
"Chrome > 31",
"ff > 31",
"ie >= 8",
"last 10 versions",
],
grid: true,
},
"postcss-px-to-viewport-8-plugin": {
unitToConvert: "px",
viewportWidth: (file) => {
let num = 1200;
if (file.indexOf("node_modules/vant") >= 0) {
num = 375;
}
return num;
},
unitPrecision: 5,
propList: ["*"],
viewportUnit: "vw",
fontViewportUnit: "vw",
selectorBlackList: ["ignore-"],
minPixelValue: 1,
mediaQuery: true,
replace: true,
exclude: [],
include: [],
landscape: false,
landscapeUnit: "vw",
landscapeWidth: 1628,
},
},
};
};