-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
40 lines (34 loc) · 1.06 KB
/
Copy pathvite.config.ts
File metadata and controls
40 lines (34 loc) · 1.06 KB
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
import { fileURLToPath, URL } from 'node:url'
import { readFileSync } from 'node:fs'
import { defineConfig } from 'vite'
import vue from '@vitejs/plugin-vue'
const pkg = JSON.parse(readFileSync('./package.json', 'utf-8'))
const isTauri = !!process.env.TAURI_ENV_PLATFORM
// https://vite.dev/config/
export default defineConfig(async ({ mode }) => {
const plugins = [vue()]
// Vue DevTools 仅在纯浏览器开发模式下启用
// Tauri 环境和生产构建完全排除,避免在 popout 小窗注入浮动按钮
if (mode === 'development' && !isTauri) {
const vueDevTools = (await import('vite-plugin-vue-devtools')).default
plugins.push(vueDevTools() as any)
}
return {
plugins,
define: {
'__APP_VERSION__': JSON.stringify(pkg.version),
},
resolve: {
alias: {
'@': fileURLToPath(new URL('./src', import.meta.url))
},
},
// Tauri: clearScreen false 避免 Tauri 误判 dev server 退出
clearScreen: false,
server: {
host: '0.0.0.0',
port: 5173,
strictPort: true,
},
}
})