lkxian888 / postcss-px-to-viewport-8-plugin

解决 postcss-px-to-viewport 控制台输出: postcss.plugin was deprecated. Migration guide:
161 stars 27 forks source link

feat(🤡): 如果是大写的 PX , 那么就扭转为小写的,忽略转换,保留原单位 #16

Open JuctTr opened 1 year ago

JuctTr commented 1 year ago

增加一个特性,如果是大写的 PX , 那么就扭转为小写的,忽略转换,保留原单位,如下:

input

.test {
  width: 20px;
  height: 20px;

  font-size: 20PX;
  border: 10PX solid red;
}

output

.test {
  width: 2.66666667vw;
  height: 2.66666667vw;

  font-size: 20px;
  border: 10px solid red;
}
lihanspace commented 6 months ago

没必要这么搞吧,px该怎么写就怎么写,想转单位的话,自定义一个最好,比如小程序的rpx。 这样只把rpx转为vw,其他的不受影响。

module.exports = {
  plugins: {
    tailwindcss: {},
    autoprefixer: {},
    'postcss-px-to-viewport-8-plugin': {
      unitToConvert: 'rpx',
      viewportWidth: 750,
      viewportUnit: 'vw',
      fontViewportUnit: 'vw',
      mediaQuery: true,
      include: [/assets/, /components/, /layouts/, /pages/, /public\/css/, /app\.vue/, /error\.vue/],
      landscape: false,
      landscapeUnit: 'vw',
      landscapeWidth: 750,
    },
    ...(process.env.NODE_ENV === 'production' ? { cssnano: {} } : {}),
  },
}