1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
| const path = require('path');
|
| module.exports = ({
| file
| }) => {
| const designWidth = file.dirname.includes(path.join('node_modules', 'vant')) ? 375 : 750;
|
| return {
| plugins: {
| autoprefixer: {},
| "postcss-px-to-viewport": {
| unitToConvert: "px", //需要转换的单位,默认为"px"
| viewportWidth: designWidth, // 视窗的宽度,对应的是我们设计稿的宽度,一般是750
| unitPrecision: 6, // 指定`px`转换为视窗单位值的小数位数
| propList: ["*"],
| viewportUnit: "vw", //指定需要转换成的视窗单位,建议使用vw
| fontViewportUnit: "vw", //字体使用的视口单位
| selectorBlackList: ['.ignore', '.el-'], // 指定不转换为视窗单位的类,可以自定义,可以无限添加,建议定义一至两个通用的类名
| minPixelValue: 1, // 小于或等于`1px`不转换为视窗单位,你也可以设置为你想要的值
| mediaQuery: true, // 允许在媒体查询中转换`px`
| exclude: [],
| landscape: false, //是否添加根据 landscapeWidth 生成的媒体查询条件 @media (orientation: landscape)
| landscapeUnit: 'vw', //(String) 横屏时使用的单位
| landscapeWidth: 750, //(Number) 横屏时使用的视口宽度
| }
| }
| }
|
| }
|
|