postcss.config.js 1.79 KB
/*
 * @Description: 
 * @Author: huyue
 * @Date: 2022-10-10 10:59:01
 * @LastEditors: huyue
 * @LastEditTime: 2023-09-04 11:19:31
 */
module.exports = {
  "plugins": {
    // "postcss-pxtorem": {
    //   rootValue: 75, // 75 表示 750 设计稿,37.5 表示 37.5 表示 375 设计稿
    //   unitPrecision: 6, // 计算结果保留 6 位小数
    //   selectorBlackList: ['.no-rem', 'no-rem'], // 要忽略的选择器并保留为px
    //   propList: ['*'], // 可以从 px 更改为 rem 的属性  感叹号开头的不转化
    //   replace: true, // 转换成 rem 以后,不保留原来的 px 单位属性
    //   mediaQuery: true, // 允许在媒体查询中转换 px
    //   minPixelValue: 2, // 设置要替换的最小像素值
    //   // exclude: /node_modules/i // 排除 node_modules 文件(node_modules 内文件禁止转换)
    // }
    'postcss-px-to-viewport': {
      unitToConvert: "px", // 要转化的单位       
      viewportWidth: 750, // UI设计稿的宽度       
      unitPrecision: 6, // 转换后的精度,即小数点位数       
      propList: ["*"], // 指定转换的css属性的单位,*代表全部css属性的单位都进行转换     
      viewportUnit: "vw", // 指定需要转换成的视窗单位,默认vw       
      fontViewportUnit: "vw", // 指定字体需要转换成的视窗单位,默认vw      selectorBlackList: ["wrap"], // 指定不转换为视窗单位的类名,       
      minPixelValue: 2, // 默认值1,小于或等于1px则不进行转换       
      mediaQuery: true, // 是否在媒体查询的css代码中也进行转换,默认false      
      replace: true, // 是否转换后直接更换属性值       
      exclude: [/node_modules/], // 设置忽略文件,用正则做目录名匹配       
    }
  }
}