From 988d45dc860751d49ce9a8de002a4d6b0b347680 Mon Sep 17 00:00:00 2001 From: zhaoguoqiang <849348323@qq.com> Date: Wed, 18 Aug 2021 16:03:25 +0800 Subject: [PATCH] =?UTF-8?q?=E8=AE=BE=E9=85=8D750?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- postcss.config.js | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) 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}`; - }, - }, } } }