-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpostcss.config.js
49 lines (49 loc) · 1.72 KB
/
postcss.config.js
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
const path = require('path')
const webpack = require('webpack')
const {WeappTailwindcssDisabled} = require('./platform')
const config = {
parser: require('postcss-comment'),
plugins: [
require('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
}
}),
require('tailwindcss')({config: './tailwind.config.js'}),
// rem 转 rpx
WeappTailwindcssDisabled
? undefined
: require('postcss-rem-to-responsive-pixel')({
rootValue: 32,
propList: ['*'],
transformUnit: 'rpx'
}),
require('autoprefixer')({
remove: process.env.UNI_PLATFORM !== 'h5'
}),
// 对于头部包含注释/*postcss-pxtransform disable*/ 的文件,插件不予处理。
require('postcss-pxtransform')({
platform: 'weapp',
designWidth: 750,
onePxTransform: true,
unitPrecision: 5,
propList: ['*'],
selectorBlackList: [],
replace: true,
mediaQuery: false,
minPixelValue: 0
}),
require('@dcloudio/vue-cli-plugin-uni/packages/postcss')
]
}
if (webpack.version[0] > 4) {
delete config.parser
}
module.exports = config