Open History to see the last commit
1import tailwindcss from "@tailwindcss/vite";
2import react from "@vitejs/plugin-react";
3import { tanstackRouter } from "@tanstack/router-plugin/vite";
4import { defineConfig } from "vite";
5import { version } from "./package.json" with { type: "json" };
6
7const port = Number(process.env.PORT ?? 5733);
8const sourcemapEnv = process.env.T3CODE_WEB_SOURCEMAP?.trim().toLowerCase();
9
10const buildSourcemap =
11 sourcemapEnv === "0" || sourcemapEnv === "false"
12 ? false
13 : sourcemapEnv === "hidden"
14 ? "hidden"
15 : true;
16
17export default defineConfig({
18 plugins: [
19 tanstackRouter(),
20 react({
21 babel: {
22 plugins: [["babel-plugin-react-compiler", { target: "19" }]],
23 },
24 }),
25 tailwindcss(),
26 ],
27 optimizeDeps: {
28 include: ["@pierre/diffs", "@pierre/diffs/react", "@pierre/diffs/worker/worker.js"],
29 },
30 define: {
31 // In dev mode, tell the web app where the WebSocket server lives
32 "import.meta.env.VITE_WS_URL": JSON.stringify(process.env.VITE_WS_URL ?? ""),
33 "import.meta.env.APP_VERSION": JSON.stringify(version),
34 },
35 resolve: {
36 tsconfigPaths: true,
37 },
38 server: {
39 port,
40 strictPort: true,
41 hmr: {
42 // Explicit config so Vite's HMR WebSocket connects reliably
43 // inside Electron's BrowserWindow. Vite 8 uses console.debug for
44 // connection logs — enable "Verbose" in DevTools to see them.
45 protocol: "ws",
46 host: "localhost",
47 },
48 },
49 build: {
50 outDir: "dist",
51 emptyOutDir: true,
52 sourcemap: buildSourcemap,
53 },
54});