vue-cli3中px2rem-loader和lib-flexible的安裝和配置

配置

安裝1:npm i postcss-px2rem --save -dev

安裝2:npm i lib-flexible --save 

(在項目中啓動vue ui也可以快速安裝)

配置1:入口文件main.js中引入:import 'lib-flexible/flexible.js'

配置2: 在vue.config.js

module.exports = {
    css: {

        loaderOptions: {

            css: {

                // options here will be passed to css-loader

            },

            postcss: {

                // options here will be passed to postcss-loader

                plugins: [require('postcss-px2rem')({

                    remUnit: 75  //設計稿的尺寸是750px 就需要除2,這裏是375px

                })]

            }

        }

    }
};

 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章