main
ts 38 lines 926 Bytes
Raw
1 import { defineConfig } from "vite";
2 import react from "@vitejs/plugin-react";
3 import path from "path";
4
5 // @ts-expect-error process is a nodejs global
6 const host = process.env.TAURI_DEV_HOST;
7
8 // https://vite.dev/config/
9 export default defineConfig(async () => ({
10 plugins: [react()],
11
12 // Vite options tailored for Tauri development and only applied in `tauri dev` or `tauri build`
13 //
14 // 1. prevent Vite from obscuring rust errors
15 clearScreen: false,
16 // 2. tauri expects a fixed port, fail if that port is not available
17 server: {
18 port: 1420,
19 strictPort: true,
20 host: host || false,
21 hmr: host
22 ? {
23 protocol: "ws",
24 host,
25 port: 1421,
26 }
27 : undefined,
28 watch: {
29 // 3. tell Vite to ignore watching `src-tauri`
30 ignored: ["**/src-tauri/**"],
31 },
32 },
33 resolve: {
34 alias: {
35 "@": path.resolve(__dirname, "./src"),
36 },
37 },
38 }));