Browse Source

设配750

pull/14/head^2
zhaoguoqiang 3 years ago
parent
commit
988d45dc86
  1. 14
      postcss.config.js

14
postcss.config.js

@ -1,18 +1,20 @@
const path = require('path'); const path = require('path');
const unit = require('./src/config/translatedUnit_server');
// const unit = require('./src/config/translatedUnit_server');
module.exports = ({ module.exports = ({
file file
}) => { }) => {
const designWidth = file.dirname.includes(path.join('node_modules', 'vant')) ? 375 : 750; 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 { return {
plugins: { plugins: {
autoprefixer: {}, autoprefixer: {},
"postcss-px-to-viewport": { "postcss-px-to-viewport": {
unitToConvert: "px", unitToConvert: "px",
viewportWidth: designWidth,
viewportWidth: rootValue,
propList: ["*"], propList: ["*"],
unitPrecision: 4, // 转换后的精度,即小数点位数
unitPrecision: 2, // 转换后的精度,即小数点位数
viewportUnit: "vw", viewportUnit: "vw",
fontViewportUnit: "vw", fontViewportUnit: "vw",
selectorBlackList: [], selectorBlackList: [],
@ -23,12 +25,6 @@ module.exports = ({
mediaQuery: true, mediaQuery: true,
exclude: [], exclude: [],
landscape: false, landscape: false,
rules: {
path: 'vant',
fn(pixels, translated) {
return `${translated * 2}${unit.vw}`;
},
},
} }
} }
} }

Loading…
Cancel
Save