generated from widcardw/vue-tsx-starter-lite
-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
108 lines (99 loc) · 2.83 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
106
107
108
/// <reference types="vitest" />
import path from 'node:path'
import { defineConfig } from 'vite'
import Vue from '@vitejs/plugin-vue'
import VueJsx from '@vitejs/plugin-vue-jsx'
import UnoCSS from 'unocss/vite'
import Pages from 'vite-plugin-pages'
import AutoImport from 'unplugin-auto-import/vite'
import PiniaAutoRefs from 'pinia-auto-refs'
import Components from 'unplugin-vue-components/vite'
import { ElementPlusResolver } from 'unplugin-vue-components/resolvers'
import VueMacros from 'unplugin-vue-macros/vite'
import IconsResolver from 'unplugin-icons/resolver'
import VueDevtools from 'vite-plugin-vue-devtools'
import ViteRestart from 'vite-plugin-restart'
// https://vitejs.dev/config/
export default defineConfig({
resolve: {
alias: {
'@/': `${path.resolve(__dirname, 'src')}/`
},
extensions: ['.js', '.json', '.ts', '.tsx', '.jsx']
},
plugins: [
VueMacros({
defineOptions: false,
defineModels: false,
plugins: {
vue: Vue({
script: {
propsDestructure: true,
defineModel: true
}
}),
vueJsx: VueJsx()
}
}),
ViteRestart({
restart: ['vite.config.[jt]s']
}),
VueDevtools(),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: [
'vue',
'pinia',
'vue-router',
'@vueuse/core',
{
alova: ['useRequest', 'useWatcher', 'useFetcher']
},
{
'@/helper/pinia-auto-refs': ['useStore']
}
],
resolvers: [
// Auto import UI components
// 自动导入ElementPlus组件
ElementPlusResolver(),
// Auto import icon components
// 自动导入图标组件
IconsResolver()
],
dts: true,
dirs: ['./src/components', './src/store', './src/composables'],
vueTemplate: false,
eslintrc: {
enabled: false, // Default `false`
filepath: './.eslintrc-auto-import.json', // Default `./.eslintrc-auto-import.json`
globalsPropValue: true // Default `true`, (true | false | 'readonly' | 'readable' | 'writable' | 'writeable')
}
}),
// https://github.com/Allen-1998/pinia-auto-refs
PiniaAutoRefs(),
// https://github.com/antfu/vite-plugin-components
Components({
resolvers: [
// Auto register icon components
// 自动注册图标组件
IconsResolver({
enabledCollections: ['ep']
}),
// Auto register Element Plus components
// 自动导入 Element Plus 组件
ElementPlusResolver()
],
dts: true,
include: [/\.vue$/, /\.vue\?vue/, /\.md$/, /\.tsx$/]
}),
UnoCSS(),
Pages({
extensions: ['ts', 'js', 'tsx', 'jsx']
})
],
// https://github.com/vitest-dev/vitest
test: {
environment: 'jsdom'
}
})