-
-
Notifications
You must be signed in to change notification settings - Fork 98
Expand file tree
/
Copy pathvite.config.ts
More file actions
105 lines (102 loc) · 3.03 KB
/
vite.config.ts
File metadata and controls
105 lines (102 loc) · 3.03 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
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
import path from "node:path";
import babel from "@rolldown/plugin-babel";
import tailwindcss from "@tailwindcss/vite";
import react from "@vitejs/plugin-react";
import { defineConfig } from "vitest/config";
const host = process.env.TAURI_DEV_HOST;
const WATCH_IGNORED = [
"**/src-tauri/**",
"**/.local/**",
"**/.local-docs/**",
"**/.vscode/**",
"**/dist/**",
"**/*.log",
];
// https://vite.dev/config/
export default defineConfig(async () => ({
plugins: [
react(),
babel({
plugins: [["babel-plugin-react-compiler", {}]],
}),
tailwindcss(),
],
resolve: {
dedupe: ["react", "react-dom"],
alias: {
"@": path.resolve(__dirname, "./src"),
react: path.resolve(__dirname, "./node_modules/react"),
"react-dom": path.resolve(__dirname, "./node_modules/react-dom"),
"react/jsx-runtime": path.resolve(
__dirname,
"./node_modules/react/jsx-runtime.js",
),
"react/jsx-dev-runtime": path.resolve(
__dirname,
"./node_modules/react/jsx-dev-runtime.js",
),
},
},
optimizeDeps: {
include: [
"react",
"react-dom",
"react/jsx-runtime",
"react/jsx-dev-runtime",
"@tanstack/react-query",
// Pre-bundle lucide-react so Vite does not have to crawl the
// per-icon ESM modules on every cold dev start. Production builds
// already tree-shake to only the icons we actually use.
"lucide-react",
],
// Lexical's package graph produces many transient dev-only chunks.
// When Vite re-optimizes mid-session after a lockfile check, those
// generated chunk names can drift and leave stale references behind.
// Excluding Lexical avoids the broken half-optimized cache state.
exclude: ["lexical", "@lexical/react"],
},
// 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. ignore app-internal local data/docs, Rust backend, editor metadata, logs, and build artifacts
ignored: WATCH_IGNORED,
},
},
test: {
environment: "jsdom",
setupFiles: "./src/test/setup.ts",
css: true,
// GitHub Actions macos-latest runs ~50x slower than local for the
// same spec (transform + import easily consume tens of seconds
// before the first test runs). waitFor-heavy tests in the nav +
// app-shortcuts suites hit microtask ordering edges under that
// load. Retry twice in CI so a single scheduling hiccup does not
// fail the whole run; local dev stays strict.
retry: process.env.CI ? 2 : 0,
// Sidecar tests are written for `bun:test`, not vitest. Exclude them
// so `bun run test:frontend` doesn't trip on `import ... from "bun:test"`.
// Same for the Rust + fixtures trees which contain no TS tests.
exclude: [
"**/node_modules/**",
"**/dist/**",
"sidecar/**",
"src-tauri/**",
"fixtures/**",
"e2e/**",
],
},
}));