40 lines
1.6 KiB
JavaScript
40 lines
1.6 KiB
JavaScript
|
|
const path = require('path')
|
|||
|
|
module.exports = {
|
|||
|
|
parser: 'postcss-comment',
|
|||
|
|
plugins: {
|
|||
|
|
'postcss-import': {
|
|||
|
|
resolve(id, basedir, importOptions) {
|
|||
|
|
if (id.startsWith('~@/')) {
|
|||
|
|
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(3))
|
|||
|
|
} else if (id.startsWith('@/')) {
|
|||
|
|
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(2))
|
|||
|
|
} else if (id.startsWith('/') && !id.startsWith('//')) {
|
|||
|
|
return path.resolve(process.env.UNI_INPUT_DIR, id.substr(1))
|
|||
|
|
}
|
|||
|
|
return id
|
|||
|
|
}
|
|||
|
|
},
|
|||
|
|
'autoprefixer': {
|
|||
|
|
overrideBrowserslist: ["Android >= 4", "ios >= 8"],
|
|||
|
|
remove: process.env.UNI_PLATFORM !== 'h5'
|
|||
|
|
},
|
|||
|
|
// 借助postcss-px-to-viewport插件,实现px转rem,文档:https://github.com/evrone/postcss-px-to-viewport/blob/master/README_CN.md
|
|||
|
|
// 以下配置,可以将px转换为rem,如果要调整比例,可以调整 viewportWidth 来实现
|
|||
|
|
'postcss-px-to-viewport': {
|
|||
|
|
unitToConvert: 'rpx', // 需要转换的单位。我这里是px,如果你的项目都是用的rpx,就改成rpx
|
|||
|
|
viewportWidth: 1600,// 密度,一般为750 || 375。这里可以自己修改
|
|||
|
|
unitPrecision: 5,
|
|||
|
|
propList: ['*'],
|
|||
|
|
viewportUnit: "rem", // 指定需要转换成的视窗单位,默认vw
|
|||
|
|
fontViewportUnit: 'rem', // 字体需要转成的单位,只针对 font-size 属性
|
|||
|
|
selectorBlackList: [],
|
|||
|
|
minPixelValue: 1,
|
|||
|
|
mediaQuery: false,
|
|||
|
|
replace: true,
|
|||
|
|
exclude: undefined,
|
|||
|
|
include: undefined,
|
|||
|
|
landscape: false
|
|||
|
|
},
|
|||
|
|
'@dcloudio/vue-cli-plugin-uni/packages/postcss': {}
|
|||
|
|
}
|
|||
|
|
}
|