自动将px转化为vw
1、安装依赖
npm install postcss-loader --save
npm install postcss-px-to-viewport --save
2、修改webpack.config.js配置文件
假如这段代码
require('postcss-px-to-viewport')({
viewportWidth: 1920, // (Number) The width of the viewport.
viewportHeight: 1080, // (Number) The height of the viewport.
unitPrecision: 3, // (Number) The decimal numbers to allow the REM units to grow to.
viewportUnit: "vw", // (String) Expected units.
selectorBlackList: [], // (Array) The selectors to ignore and leave as px.
minPixelValue: 1, // (Number) Set the minimum pixel value to replace.
mediaQuery: false // (Boolean) Allow px to be converted in media queries.
}),