postcss.config.js 1.4 KB

module.exports = {
  plugins: {
    // postcss-pxtorem 插件的版本需要 >= 5.0.0
    // 适用版本 5.1.1
    // yarn add -D postcss-pxtorem@5.1.1
    // npm install postcss-pxtorem@5.1.1 -D
    'postcss-pxtorem': {
      // rootValue ({ file }) { // 判断是否是vant的文件 如果是就使用 37.5为根节点字体大小
      //   // 否则使用75 因为vant使用的设计标准为375 但是市场现在的主流设置尺寸是750
      //   return 75;
      //   // file.indexOf('vant') !== -1 ? 37.5 : 75;
      // },
      // 配置哪些文件中的尺寸需要转化为rem *表示所有的都要转化
      propList: ['*'],
      // selectorBlackList: ['#live-nav'],
      rootValue: 37.5, //表示根元素字体大小
      unitPrecision: 3, //小数点后保留位数
      // propList: ['font', 'font-size', 'line-height', 'height', 'letter-spacing', 'padding', 'margin', 'width', 'border-radius', 'background', 'background-size'],//需要转换的属性列表
      selectorBlackList: [],//忽略不需要转换的选择器
      replace: true,//是否直接更换属性值,而不添加备用属性
      mediaQuery: false,//是否在媒体查询的css代码中也进行转换,默认为false
      minPixelValue: 1,//设置最小的转换数值,如果为1的话,代表只有大于1的值会被转换
      exclude: false,//设置忽略文件的正则,例如:/(node_module)/
    },
  },
};