-
Notifications
You must be signed in to change notification settings - Fork 79
/
postcss.config.js
44 lines (43 loc) · 1.18 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
if (process.env.VITE_ROOT_DIR) { // vite
const {
uniPostcssPlugin,
parseRpx2UnitOnce,
} = require('@dcloudio/uni-cli-shared')
module.exports = {
plugins: [
uniPostcssPlugin(
Object.assign({
page: process.env.UNI_PLATFORM === 'h5' ? 'uni-page-body' : 'body'
},
parseRpx2UnitOnce(process.env.UNI_INPUT_DIR)
)
),
require('autoprefixer')(),
],
}
} else {
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: ["> 1%", "last 2 versions", "not dead"],
remove: process.env.UNI_PLATFORM !== 'h5',
ignoreUnknownVersions: true
},
'@dcloudio/vue-cli-plugin-uni/packages/postcss': {}
}
}
}