46 lines
1.6 KiB
JavaScript
46 lines
1.6 KiB
JavaScript
// postcss.config.cjs
|
||
/*
|
||
使用方式:
|
||
正常启用(默认):npm run dev
|
||
临时禁用:ENABLE_PX_TO_VW=false npm run dev
|
||
*/
|
||
// const isPxToVwEnabled = process.env.ENABLE_PX_TO_VW !== 'false'
|
||
// module.exports = {
|
||
// plugins: {
|
||
// ...(isPxToVwEnabled && {
|
||
// 'postcss-px-to-viewport': {
|
||
// unitToConvert: 'px', // 需要转换的单位,默认为"px"
|
||
// viewportWidth: 750, // 设计稿的视口宽度(如常见的750px)
|
||
// unitPrecision: 5, // 转换后的精度,即小数点位数
|
||
// propList: ['*'], // 匹配的属性列表,'*'表示全部属性
|
||
// viewportUnit: 'vw', // 转换后的视口单位
|
||
// fontViewportUnit: 'vw', // 字体使用的视口单位
|
||
// selectorBlackList: [], // 需要忽略的选择器
|
||
// minPixelValue: 1, // 最小的转换数值
|
||
// mediaQuery: false, // 是否在媒体查询中也进行转换
|
||
// replace: true, // 是否直接替换而不添加备用属性
|
||
// exclude: [/node_modules/], // 忽略的文件路径
|
||
// include: undefined, // 如果设置了include,只有匹配到的文件才会被转换
|
||
// landscape: false // 是否添加横向的媒体查询
|
||
// }
|
||
// })
|
||
// }
|
||
// }
|
||
|
||
// postcss.config.cjs
|
||
module.exports = {
|
||
plugins: {
|
||
'postcss-px-to-viewport-8-plugin': {
|
||
unitToConvert: 'px',
|
||
viewportWidth: 750,
|
||
unitPrecision: 5,
|
||
viewportUnit: 'vw',
|
||
fontViewportUnit: 'vw',
|
||
selectorBlackList: [],
|
||
minPixelValue: 1,
|
||
mediaQuery: false,
|
||
exclude: [/node_modules/]
|
||
}
|
||
}
|
||
}
|