postcss-pxr-to-rem

pxr=px2rem

Usage no npm install needed!

<script type="module">
  import postcssPxrToRem from 'https://cdn.skypack.dev/postcss-pxr-to-rem';
</script>

README

npm install postcss-pxr-to-rem

.postcssrc.js配置

module.exports = {
  "plugins": {
    ...
    "autoprefixer": {},
    ...
    "postcss-pxr-to-rem": {
        pixel: 50,
        fontSize: 1,
        unit: 'rem',
        mediaQuery: false,
        selectorBlackList: []
    }
  }
}

css

stylus --- 可自定义
@media only screen and (max-width 320px)
    html
        font-size 42px
@media only screen and (min-width 320px)
    html
        font-size 42.6667px
@media only screen and (min-width 375px)
    html
        font-size 50px
@media only screen and (min-width 414px)
    html
        font-size 55.2px
@media only screen and (min-width 641px)
    html
        font-size 85.4667px
@media only screen and (min-width 769px)
    html
        font-size 50px

npm login --registry http://registry.npmjs.org npm publish --registry http://registry.npmjs.org