Files
Thing/vite.config.ts
T
2026-07-22 22:26:40 +08:00

56 lines
1.3 KiB
TypeScript

import { fileURLToPath, URL } from "node:url"
import { defineConfig } from "vite";
import tailwindcss from "@tailwindcss/vite"
import vue from "@vitejs/plugin-vue";
const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/
export default defineConfig(async () => ({
plugins: [
vue(),
tailwindcss(),
],
resolve: {
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
},
},
// 单入口:主窗口
build: {
rollupOptions: {
input: {
main: fileURLToPath(new URL("./index.html", import.meta.url)),
},
},
},
// 防止 Vite 缓存 tauri-plugin-snap-layout,否则注入脚本中的占位符无法被替换
optimizeDeps: {
exclude: ["tauri-plugin-snap-layout"],
},
// 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/**"],
},
},
}));