-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
74 lines (64 loc) · 2 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
/// <reference types="vitest" />
import { resolve } from 'node:path'
import { defineConfig } from 'vite'
import uni from '@dcloudio/vite-plugin-uni'
import UniPages from '@uni-helper/vite-plugin-uni-pages'
import UniLayouts from '@uni-helper/vite-plugin-uni-layouts'
import AutoImport from 'unplugin-auto-import/vite'
import Components from 'unplugin-vue-components/vite'
import ReactivityTransform from '@vue-macros/reactivity-transform/vite'
// import Unocss from 'unocss/vite'
import VueDevTools from 'vite-plugin-vue-devtools'
// https://vitejs.dev/config/
export default defineConfig(async () => {
/**
* unocss@0.59.x版本后仅支持ESM,使用动态导入来兼容uni(Uni采用的是CommonJS,不支持ESM库)
* @see https://github.com/dcloudio/uni-app/issues/4815
*/
const UnoCSS = await import('unocss/vite').then(i => i.default)
return {
resolve: {
alias: {
'~/': `${resolve(__dirname, 'src')}/`,
},
},
plugins: [
// https://github.com/uni-helper/vite-plugin-uni-pages
UniPages({
dts: 'src/uni-pages.d.ts',
}),
// https://github.com/uni-helper/vite-plugin-uni-layouts
UniLayouts(),
// https://github.com/unplugin/unplugin-auto-import
AutoImport({
imports: [
'vue',
'uni-app',
],
dts: 'src/auto-imports.d.ts',
dirs: [
'./src/composables',
'./src/stores',
],
vueTemplate: true,
}),
// https://github.com/unplugin/unplugin-vue-components
Components({
dts: 'src/components.d.ts',
types: [],
}),
// https://vue-macros.sxzz.moe/zh-CN/features/reactivity-transform.html
ReactivityTransform(),
// https://github.com/dcloudio/uni-app
uni(),
// https://github.com/unocss/unocss
UnoCSS(),
// https://github.com/webfansplz/vite-plugin-vue-devtools
VueDevTools(),
],
// https://github.com/vitest-dev/vitest
test: {
environment: 'jsdom',
},
}
})