-
-
Notifications
You must be signed in to change notification settings - Fork 12
/
vite.config.ts
47 lines (39 loc) · 1.19 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
import path from 'node:path'
import type { UserConfig } from 'vite'
import { defineConfig, loadEnv } from 'vite'
import Vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import Unocss from 'unocss/vite'
import { domToCodePlugin } from 'dom-to-code/vite'
import { switchVersion } from 'vue-demi/scripts/utils.js'
const pathResolve = (...args: string[]) => path.resolve(__dirname, ...args)
switchVersion(3)
export default defineConfig(({ mode }) => {
// 根据当前工作目录中的“mode”加载env文件。
// 将第三个参数设置为 '' 以加载所有 env
// eslint-disable-next-line @typescript-eslint/no-unused-vars
const env = loadEnv(mode, process.cwd(), '')
return {
resolve: {
dedupe: ['vue', 'vue-demi'], // use the same version
alias: {
'@/': `${pathResolve('./src')}/`,
},
},
plugins: [
// vue3 语法支持
Vue({
include: [/\.vue$/],
reactivityTransform: true,
}),
vueJsx(),
// https://github.com/antfu/unocss
// 有关配置,请参见 unocss.config.ts
Unocss(),
domToCodePlugin(),
],
server: {
host: true,
},
} as UserConfig
})