-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathvite.config.ts
More file actions
111 lines (100 loc) · 3.23 KB
/
vite.config.ts
File metadata and controls
111 lines (100 loc) · 3.23 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
106
107
108
109
110
111
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import { fileURLToPath, URL } from "node:url";
import { createRequire } from "node:module";
import { sentryVitePlugin } from "@sentry/vite-plugin";
import tailwindcss from "@tailwindcss/vite";
const host = process.env.TAURI_DEV_HOST;
const disableSourcemaps = process.env.VITE_DISABLE_SOURCEMAPS === "true";
const require = createRequire(import.meta.url);
const antlr4BrowserEntry = (() => {
try {
return require.resolve("antlr4/dist/antlr4.web.mjs");
} catch {
return fileURLToPath(
new URL(
"./node_modules/.pnpm/node_modules/antlr4/dist/antlr4.web.mjs",
import.meta.url,
),
);
}
})();
// https://vite.dev/config/
export default defineConfig(({ mode }) => ({
plugins: [
react(),
tailwindcss(),
// Only upload source maps in production builds when SENTRY_AUTH_TOKEN is set
...(mode === "production" &&
!disableSourcemaps &&
process.env.SENTRY_AUTH_TOKEN
? [
sentryVitePlugin({
org: process.env.SENTRY_ORG || "query-pilot",
project:
process.env.SENTRY_PROJECT_FRONTEND || "query-pilot-frontend",
authToken: process.env.SENTRY_AUTH_TOKEN,
telemetry: false, // Disable Sentry CLI telemetry
sourcemaps: {
assets: ["./dist/**"],
filesToDeleteAfterUpload: ["./dist/**/*.map"], // Clean up source maps after upload
},
}),
]
: []),
],
// Optimize dependencies for WASM support
optimizeDeps: {
exclude: ["@supabase/pg-parser"],
},
// Configure asset handling for WASM files
assetsInclude: ["**/*.wasm"],
build: {
// Generate source maps for production (uploaded to Sentry, then deleted)
sourcemap: mode === "production" && !disableSourcemaps,
},
// Configure worker format to ES modules for Web Worker support
worker: {
format: "es",
},
// Strip console.log/debug in production for performance
esbuild: {
drop: mode === "production" ? ["console", "debugger"] : [],
},
resolve: {
conditions: ["import", "default"],
alias: {
"@": fileURLToPath(new URL("./src", import.meta.url)),
"@components": fileURLToPath(
new URL("./src/components", import.meta.url),
),
"@lib": fileURLToPath(new URL("./src/lib", import.meta.url)),
"@hooks": fileURLToPath(new URL("./src/hooks", import.meta.url)),
"@types": fileURLToPath(new URL("./src/types", import.meta.url)),
"@utils": fileURLToPath(new URL("./src/utils", import.meta.url)),
// Fix antlr4 resolution for @dbml/core - use browser bundle via pnpm
antlr4: antlr4BrowserEntry,
},
},
// 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/**"],
},
},
}));