原文出處:https://www.mulingyuer.com/archives/377/
安裝插件:
1.安裝postcss-pxtorem
npm install postcss-pxtorem --save-dev
2.安裝lib-flexible.由于時間的問題镜盯,lib-flexible其實已經(jīng)棄用了,現(xiàn)在是使用名為amfe-flexible的插件川背,amfe-flexible實際上就是在lib-flexible的基礎(chǔ)上更新的领虹,所以用法都是一樣规哪。
npm i -s amfe-flexible
引入插件:
main.js文件引入
import 'amfe-flexible'
創(chuàng)建配置文件:
在根目錄,和package.json同級塌衰,創(chuàng)建一個名為postcss.config.js的文件
module.exports = {
plugins: {
'autoprefixer': {
overrideBrowserslist: [
'Android 4.1',
'iOS 7.1',
'Chrome > 31',
'ff > 31',
'ie >= 8'
]
},
'postcss-pxtorem': {
rootValue: 37.5,
propList: ['*']
}
}
}