-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathvite.config.ts
More file actions
52 lines (50 loc) · 1.75 KB
/
Copy pathvite.config.ts
File metadata and controls
52 lines (50 loc) · 1.75 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
41
42
43
44
45
46
47
48
49
50
51
52
/// <reference types="vitest/config" />
import { defineConfig } from "vite";
import react, { reactCompilerPreset } from "@vitejs/plugin-react";
import babel from "@rolldown/plugin-babel";
import tailwindcss from "@tailwindcss/vite";
const host = process.env.TAURI_DEV_HOST;
// https://vite.dev/config/
export default defineConfig(async () => ({
plugins: [react(), babel({ presets: [reactCompilerPreset()] }), tailwindcss()],
// The Tauri CLI exports TAURI_ENV_DEBUG only for debug builds, so this is true
// for `tauri dev` and `tauri build --debug` and false for a release bundle.
// Inlining it means the release bundle carries no native-context-menu bypass at all.
define: {
__TAURI_DEBUG_BUILD__: JSON.stringify(process.env.TAURI_ENV_DEBUG === "true"),
},
resolve: {
// Sonner and React DOM must resolve React to this application's single
// module instance. Without this, the macOS WebKit bundle can load a second
// copy and trigger React's "Invalid hook call" error at startup.
dedupe: ["react", "react-dom"],
tsconfigPaths: true,
},
test: {
include: ["./src/**/*.{test,spec}.{ts,tsx}"],
environment: "happy-dom",
setupFiles: ["./src/test/setup.ts"],
globals: true,
},
// 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: 5173,
strictPort: true,
host: host || false,
hmr: host
? {
protocol: "ws",
host,
port: 5174,
}
: undefined,
watch: {
// 3. tell Vite to ignore watching `src-tauri`
ignored: ["**/src-tauri/**"],
},
},
}));