diff --git a/postcss.config.js b/postcss.config.js index 56c443a..9d61be8 100644 --- a/postcss.config.js +++ b/postcss.config.js @@ -1,18 +1,20 @@ const path = require('path'); -const unit = require('./src/config/translatedUnit_server'); +// const unit = require('./src/config/translatedUnit_server'); module.exports = ({ file }) => { const designWidth = file.dirname.includes(path.join('node_modules', 'vant')) ? 375 : 750; + let isVant = file && file.dirname && file.dirname.indexOf("vant") > -1; + let rootValue = isVant ? 375 : 750; // 判断条件 请自行调整 return { plugins: { autoprefixer: {}, "postcss-px-to-viewport": { unitToConvert: "px", - viewportWidth: designWidth, + viewportWidth: rootValue, propList: ["*"], - unitPrecision: 4, // 转换后的精度,即小数点位数 + unitPrecision: 2, // 转换后的精度,即小数点位数 viewportUnit: "vw", fontViewportUnit: "vw", selectorBlackList: [], @@ -23,12 +25,6 @@ module.exports = ({ mediaQuery: true, exclude: [], landscape: false, - rules: { - path: 'vant', - fn(pixels, translated) { - return `${translated * 2}${unit.vw}`; - }, - }, } } }