-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
vite.config.ts
93 lines (88 loc) · 2.98 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
/// <reference types="vitest" />
/* eslint-disable node/prefer-global/process */
import path from 'node:path'
import type { ConfigEnv, UserConfigExport } from 'vite'
import { loadEnv } from 'vite'
import Vue from '@vitejs/plugin-vue'
import Pages from 'vite-plugin-pages'
import Components from 'unplugin-vue-components/vite'
import AutoImport from 'unplugin-auto-import/vite'
import UnoCSS from 'unocss/vite'
import VueMacros from 'unplugin-vue-macros/vite'
import { NaiveUiResolver } from 'unplugin-vue-components/resolvers'
export default ({ mode }: ConfigEnv): UserConfigExport => {
const root = process.cwd()
const env = loadEnv(mode, root) as unknown as ImportMetaEnv
return {
worker: {
format: 'es'
},
resolve: {
alias: {
'~/': `${path.resolve(__dirname, 'src')}/`
}
},
build: {
rollupOptions: {
output: {
manualChunks: {
'vue': ['vue', '@vueuse/core', 'vue-router'],
'naive': ['naive-ui'],
'generate': ['better-mock', 'ejs', 'file-saver', 'jszip'],
'codemirror': ['codemirror', 'vue-codemirror'],
'@codemirror': ['@codemirror/lang-java', '@codemirror/lang-javascript', '@codemirror/theme-one-dark']
}
}
}
},
base: env.VITE_BASE_URL,
plugins: [
VueMacros({
plugins: {
vue: Vue({})
}
}),
// https://github.com/hannoeru/vite-plugin-pages
Pages(),
// https://github.com/antfu/unplugin-auto-import
AutoImport({
imports: [
'vue',
'vue/macros',
'vue-router',
'@vueuse/core'
],
dts: true,
dirs: [
'./src/composables'
],
vueTemplate: true
}),
// https://github.com/antfu/vite-plugin-components
Components({
dts: true,
resolvers: [
NaiveUiResolver()
],
include: [/\.vue$/, /\.vue\?vue/, /\.md$/]
}),
// https://github.com/antfu/unocss
// see uno.config.ts for config
UnoCSS()
],
// Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
//
// 1. prevent vite from obscuring rust errors
clearScreen: false,
// 2. tauri expects a fixed port, fail if that port is not available
server: {
port: 3333,
strictPort: true,
host: false,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ['**/src-tauri/**']
}
}
}
}