-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathuno.config.ts
54 lines (49 loc) · 1.43 KB
/
uno.config.ts
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
50
51
52
53
54
import process from 'node:process'
import {
defineConfig,
presetAttributify,
transformerDirectives,
transformerVariantGroup,
} from 'unocss'
import {
presetApplet,
presetRemRpx,
transformerApplet,
transformerAttributify,
} from 'unocss-applet'
import type { Preset } from 'unocss'
const isH5 = process.env?.UNI_PLATFORM === 'h5'
const isMp = process.env?.UNI_PLATFORM?.startsWith('mp') ?? false
const presets: Preset[] = []
if (!isMp) presets.push(presetAttributify())
if (!isH5) presets.push(presetRemRpx())
/**
* 最终会得到:
* mp 里面:mt-4 => margin-top: 32rpx
* h5 里面:mt-4 => margin-top: 1rem
*/
export default defineConfig({
rules: [
['pt-safe', { 'padding-top': 'env(safe-area-inset-top)' }],
['pb-safe', { 'padding-bottom': 'env(safe-area-inset-bottom)' }],
['p-safe', { padding: 'env(safe-area-inset-top) env(safe-area-inset-right) env(safe-area-inset-bottom) env(safe-area-inset-left)' }],
],
shortcuts: {
'full': 'w-full h-full',
'flex-col': 'flex flex-col',
'flex-items': 'flex items-center',
'flex-b-c': 'flex justify-between items-center',
'flex-center': 'flex justify-center items-center',
'flex-col-center': 'flex flex-col justify-center items-center',
},
presets: [
presetApplet({ enable: !isH5 }),
...presets,
],
transformers: [
transformerDirectives(),
transformerVariantGroup(),
transformerAttributify(),
transformerApplet(),
],
})