-
Notifications
You must be signed in to change notification settings - Fork 15
/
vite.config.ts
114 lines (107 loc) · 2.84 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
110
111
112
113
114
/* eslint-disable new-cap */
import { resolve } from 'node:path'
import Vue from '@vitejs/plugin-vue'
import vueJsx from '@vitejs/plugin-vue-jsx'
import { internalIpV4 } from 'internal-ip'
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 Layouts from 'vite-plugin-vue-layouts'
const mobile = !!/android|ios/.exec(process.env.TAURI_ENV_PLATFORM)
// https://vitejs.dev/config/
export default defineConfig(async () => ({
plugins: [
VueMacros({
plugins: {
vue: Vue(),
vueJsx: vueJsx(),
},
betterDefine: false,
}),
VueRouter({
routesFolder: 'src/views',
dts: 'src/typed-router.d.ts',
}),
Layouts({
pagesDirs: 'src/views',
}),
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: {
'~': resolve(__dirname, 'src'),
},
},
css: {
postcss: {
plugins: [postcssNesting()],
},
modules: {
localsConvention: 'camelCaseOnly' as const,
},
},
define: {
'process.env': {},
},
// 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: mobile ? '0.0.0.0' : false,
hmr: mobile
? {
protocol: 'ws',
host: await internalIpV4(),
port: 1421,
}
: undefined,
watch: {
// 3. tell vite to ignore watching `src-tauri`
ignored: ['**/src-tauri/**'],
},
},
}))