-
Notifications
You must be signed in to change notification settings - Fork 15
/
vite.config.ts
109 lines (102 loc) · 2.75 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
109
/* eslint-disable new-cap */
import path from 'node:path'
import Vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import postcssNesting from 'postcss-nesting'
import UnoCSS from 'unocss/vite'
import AutoImport from 'unplugin-auto-import/vite'
import Info from 'unplugin-info/vite'
import TurboConsole from 'unplugin-turbo-console/vite'
import Components from 'unplugin-vue-components/vite'
import VueMacros from 'unplugin-vue-macros/vite'
import { VueRouterAutoImports } from 'unplugin-vue-router'
import VueRouter from 'unplugin-vue-router/vite'
import { defineConfig } from 'vite'
import VueDevTools from 'vite-plugin-vue-devtools'
import MetaLayouts from 'vite-plugin-vue-meta-layouts'
import type { UserConfig } from 'vite'
const host = process.env.TAURI_DEV_HOST
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
VueMacros({
plugins: {
vue: Vue(),
vueJsx: vueJsx(),
vueRouter: VueRouter({
routesFolder: 'src/views',
dts: 'src/typed-router.d.ts',
}),
},
betterDefine: false,
}),
MetaLayouts(),
AutoImport({
imports: [
'vue',
'@vueuse/core',
'pinia',
VueRouterAutoImports,
{
'@tauri-apps/plugin-log': [['*', 'logger']],
},
{
from: 'src/database/model',
imports: ['User', 'Friend', 'Group', 'Member', 'CacheFile'],
type: true,
},
],
dirs: ['src/composables', 'src/database', 'src/stores', 'src/utils'],
dts: 'src/auto-imports.d.ts',
vueTemplate: true,
}),
Components({
dts: 'src/components.d.ts',
}),
UnoCSS(),
Info({
meta: {
isBuild: process.env.GITHUB_WORKFLOW === 'Build',
isRelease: process.env.GITHUB_WORKFLOW === 'Release',
prNum: process.env.GITHUB_PR_NUMBER,
buildSha: process.env.GITHUB_BUILD_SHA,
},
}),
TurboConsole(),
VueDevTools(),
],
resolve: {
alias: {
'~/': `${path.resolve(import.meta.dirname, 'src')}/`,
},
},
css: {
postcss: {
plugins: [postcssNesting()],
},
modules: {
localsConvention: 'camelCaseOnly',
},
},
// 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: 1420,
strictPort: true,
host: host ?? false,
hmr: host
? {
protocol: 'ws',
host,
port: 1421,
}
: undefined,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ['**/src-tauri/**'],
},
},
} satisfies UserConfig)