美文网首页
使用postcss-px2rem无法转换vue模板文件中的scs

使用postcss-px2rem无法转换vue模板文件中的scs

作者: 8d2855a6c5d0 | 来源:发表于2018-10-01 22:50 被阅读0次

    移动端的项目使用postcss-px2rem将px转换成rem,使用css时可以转换成rem但使用scss缺无法将.vue中的scss中的px转换成rem,需要在vue-loader.conf.js中添加posstcss的配置

    module.exports = {
      loaders: utils.cssLoaders({
        sourceMap: sourceMapEnabled,
        extract: isProduction
      }),
      cssSourceMap: sourceMapEnabled,
      cacheBusting: config.dev.cacheBusting,
      transformToRequire: {
        video: ['src', 'poster'],
        source: 'src',
        img: 'src',
        image: 'xlink:href'
      },
      // 添加这句话
      postcss: [require('postcss-px2rem')({remUnit: 75})]
    }
    

    vue版本

      "dependencies": {
        "normalize.css": "^8.0.0",
        "vue": "^2.5.2",
        "vue-router": "^3.0.1"
      },
    

    相关文章

      网友评论

          本文标题:使用postcss-px2rem无法转换vue模板文件中的scs

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