0.2.0 • Published 1 year ago

hxm-postcss-adaptive v0.2.0

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

hxm-postcss-adaptive

css 单位转换。目前支持 rem 比例之间的互转。

Based on postcss-adaptivehttps://github.com/songsiqi/postcss-adaptive

API

Config:

  • type:转换类型
    • remToRemrem 单位之间的比例互转
    • remToPxrem 单位转成 px
  • ratio: rem 单位之间的转换比例。(当 typeremToRem 时需要提供该参数)
  • rootValuerempx 的转换基准值。例如:0.36rem <=> 18pxrootValue 的值为 50。(当 typeremToPx 时需提供该参数)

Vue-Cli

新建 .postcssrc.json,配置如下:

{
  "plugins": {
    "postcss-adaptive": {
      "type": "remToRem",
      "ratio": 2
    }
  }
}

插件转换前:

#app {
  margin-top: 0.3rem; /*rem*/
  font-size: 0.2rem;
}

插件转换后:

#app {
  margin-top: 0.6rem; /*rem*/
  font-size: 0.4rem;
}

Changelog

0.1.0

  • First release.

0.2.0

  • 增加 remToPx 的类型及 rootValue 配置项.

License

MIT