美文网首页
在项目中使用postcss-plugin-px2rem

在项目中使用postcss-plugin-px2rem

作者: afeng_1234 | 来源:发表于2019-01-16 13:10 被阅读0次
//utils/rem.js
(function () {
  document.body.style.fontSize = '14px'
  const setRem = () => {
    let vw = document.documentElement.clientWidth
    document.documentElement.style.fontSize = vw / 7.5 + 'px'
  }
  setRem()
  window.onresize = setRem
}())

//.postcssrc.js
module.exports = {
  "plugins": {
    "postcss-import": {},
    "postcss-url": {},
    // to edit target browsers: use "browserslist" field in package.json
    "autoprefixer": {},
    "postcss-plugin-px2rem": {
      remUnit: 100,
      mediaQuery: true,
      exclude:"/node_modules/i",
      selectorBlackList: ['html', 'mint-', 'mt-', 'mpvue-', 'calendar', 'iconfont'], //在rem.js全局作用下   排除指定的文件的影响
      propBlackList: ['border']
    }
  }
}
image.png

相关文章

网友评论

      本文标题:在项目中使用postcss-plugin-px2rem

      本文链接:https://www.haomeiwen.com/subject/xcqmdqtx.html