Open History to see the last commit
1import tailwindcss from "@tailwindcss/vite";
2import react, { reactCompilerPreset } from "@vitejs/plugin-react";
3import babel from "@rolldown/plugin-babel";
4import { tanstackRouter } from "@tanstack/router-plugin/vite";
5import { defineConfig } from "vite";
6import pkg from "./package.json" with { type: "json" };
7
8const port = Number(process.env.PORT ?? 5733);
9const sourcemapEnv = process.env.T3CODE_WEB_SOURCEMAP?.trim().toLowerCase();
10
11const buildSourcemap =
12 sourcemapEnv === "0" || sourcemapEnv === "false"
13 ? false
14 : sourcemapEnv === "hidden"
15 ? "hidden"
16 : true;
17
18export default defineConfig({
19 plugins: [
20 tanstackRouter(),
21 react(),
22 babel({
23 // We need to be explicit about the parser options after moving to @vitejs/plugin-react v6.0.0
24 // This is because the babel plugin only automatically parses typescript and jsx based on relative paths (e.g. "**/*.ts")
25 // whereas the previous version of the plugin parsed all files with a .ts extension.
26 // This is causing our packages/ directory to fail to parse, as they are not relative to the CWD.
27 parserOpts: { plugins: ["typescript", "jsx"] },
28 presets: [reactCompilerPreset()],
29 }),
30 tailwindcss(),
31 ],
32 optimizeDeps: {
33 include: ["@pierre/diffs", "@pierre/diffs/react", "@pierre/diffs/worker/worker.js"],
34 },
35 define: {
36 // In dev mode, tell the web app where the WebSocket server lives
37 "import.meta.env.VITE_WS_URL": JSON.stringify(process.env.VITE_WS_URL ?? ""),
38 "import.meta.env.APP_VERSION": JSON.stringify(pkg.version),
39 },
40 resolve: {
41 tsconfigPaths: true,
42 },
43 server: {
44 port,
45 strictPort: true,
46 hmr: {
47 // Explicit config so Vite's HMR WebSocket connects reliably
48 // inside Electron's BrowserWindow. Vite 8 uses console.debug for
49 // connection logs — enable "Verbose" in DevTools to see them.
50 protocol: "ws",
51 host: "localhost",
52 },
53 },
54 build: {
55 outDir: "dist",
56 emptyOutDir: true,
57 sourcemap: buildSourcemap,
58 },
59});