vuecli 4 配置postcss
npm i amfe-flexible -S
npm i postcss-pxtorem@5.1.1 -D
创建vue.config.js
module.exports = {
css: {
loaderOptions: {
postcss: {
plugins: [
require(“autoprefixer”)({
// 配置使用 autoprefixer
overrideBrowserslist: [“last 15 versions”]
}),
require(“postcss-pxtorem”)({
rootValue: 37.5, // 换算的基数
// 忽略转换正则匹配项。插件会转化所有的样式的px。比如引入了三方UI,也会被转化。目前我使用 selectorBlackList字段,来过滤
//如果个别地方不想转化px。可以简单的使用大写的 PX 或 Px 。
selectorBlackList: [“ig”],
propList: ["*"],
exclude: /node_modules/
})
]
}
}
}
};
在mian.js中引入 import ‘amfe-flexible’