-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathvite.config.ts
105 lines (99 loc) · 2.4 KB
/
vite.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
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
import { LibraryOptions, defineConfig } from 'vite'
import { loadKylinConfig } from './scripts/config'
import {
BuildLib,
BuildPlugins,
rollupOptions,
} from './scripts/rollup/build.config'
import {
presetUno,
presetIcons,
presetAttributify,
} from 'unocss'
import Unocss from 'unocss/vite'
import react from '@vitejs/plugin-react'
import path from 'path'
import dts from 'vite-plugin-dts'
export default async () => {
const kylinConfig = await loadKylinConfig()
console.log('kylinConfig', kylinConfig)
const dynamicSafelist = await import(
'./packages/preset/dynamicSafelist'
)
const safelist = dynamicSafelist.default(kylinConfig)
return await defineConfig({
plugins: [
react(),
Unocss({
presets: [
presetUno(),
presetIcons(),
presetAttributify(),
],
shortcuts: {
'j-a-c': 'justify-center items-center',
},
safelist: [
// FLAG: 根据 开发者传入的 preset 进行 safelist 的配置
...safelist,
'h-30px',
'h-50px',
'lh-50px',
'text-white',
'text-center',
],
}),
...BuildPlugins(),
// dts({
// outputDir: './dist/types',
// insertTypesEntry: true, // 插入TS 入口
// copyDtsFiles: true, // 是否将源码里的 .d.ts 文件复制到 outputDir
// }),
],
build: {
outDir: 'dist',
sourcemap: true,
minify: 'esbuild',
cssCodeSplit: true,
lib: {
...BuildLib(),
} as LibraryOptions,
rollupOptions: {
...rollupOptions(),
},
},
define: {
'process.env.KYLIN_CONFIG':
JSON.stringify(kylinConfig),
},
resolve: {
alias: {
'@': path.resolve(path.resolve(), '/src'),
'@packages': path.resolve(
path.resolve(),
'/packages'
),
'@components': path.resolve(
path.resolve(),
'/packages/components/'
),
'@shared': path.resolve(
path.resolve(),
'/packages/shared/'
),
'@hooks': path.resolve(
path.resolve(),
'/packages/hooks/'
),
'@preset': path.resolve(
path.resolve(),
'/packages/preset/'
),
'@icon': path.resolve(
path.resolve(),
'/packages/icon/'
),
},
},
})
}