diff --git a/apps/web/vite.config.mts b/apps/web/vite.config.mts index 598543d3..ba620d97 100644 --- a/apps/web/vite.config.mts +++ b/apps/web/vite.config.mts @@ -4,6 +4,13 @@ import tailwindcss from "@tailwindcss/vite"; import react from "@vitejs/plugin-react"; import { defineConfig } from "vite"; +const appNodeModulesPath = path.resolve(__dirname, "./node_modules"); +const hmrHost = process.env.VITE_HMR_HOST; +const hmrClientPort = process.env.VITE_HMR_CLIENT_PORT + ? Number(process.env.VITE_HMR_CLIENT_PORT) + : undefined; +const hmrProtocol = process.env.VITE_HMR_PROTOCOL; + // https://vite.dev/config/ export default defineConfig({ build: { @@ -13,10 +20,26 @@ export default defineConfig({ "process.env": {}, }, plugins: [react(), tailwindcss()], + server: { + host: true, + hmr: + hmrHost || hmrClientPort || hmrProtocol + ? { + host: hmrHost, + clientPort: hmrClientPort, + protocol: hmrProtocol, + } + : undefined, + }, resolve: { - dedupe: ["react", "react-dom"], + dedupe: ["react", "react-dom", "react/jsx-runtime", "react/jsx-dev-runtime"], alias: { "@": path.resolve(__dirname, "./src"), + react: path.resolve(appNodeModulesPath, "react"), + "react-dom": path.resolve(appNodeModulesPath, "react-dom"), + "react-dom/client": path.resolve(appNodeModulesPath, "react-dom/client.js"), + "react/jsx-runtime": path.resolve(appNodeModulesPath, "react/jsx-runtime.js"), + "react/jsx-dev-runtime": path.resolve(appNodeModulesPath, "react/jsx-dev-runtime.js"), }, }, });