Skip to content

Infisical is the open-source platform for securing secrets, certificates, access, and AI Agents.

fix: resolved dev server reloading

=4ca2cf86df45
diff --git a/Makefile b/Makefile
index 5f78456512..44059a5f0f 100644
--- a/Makefile
+++ b/Makefile
@@ -16,6 +16,13 @@ up-prod:
down:
docker compose -f docker-compose.dev.yml down
+# Wipes the persisted Vite dep-prebundle cache. Reach for this when the dev server serves
+# stale or broken /node_modules/.vite/deps chunks; it re-optimizes on the next `make up-dev`.
+COMPOSE_PROJECT_NAME ?= $(notdir $(CURDIR))
+clear-frontend-cache:
+ docker compose -f docker-compose.dev.yml rm -sf frontend
+ docker volume rm -f $(COMPOSE_PROJECT_NAME)_frontend_vite_cache
+
reviewable-ui:
cd frontend && \
npm run lint:fix && \
diff --git a/docker-compose.dev.yml b/docker-compose.dev.yml
index d951284ac5..1fec16a28e 100644
--- a/docker-compose.dev.yml
+++ b/docker-compose.dev.yml
@@ -178,6 +178,10 @@ services:
- ./frontend/src:/app/src/ # mounted whole src to avoid missing reload on new files
- ./frontend/public:/app/public
- ./frontend/index.html:/app/index.html
+ # Persist Vite's optimized dep cache across container recreation. Without it a fresh
+ # container re-prebundles and hands out new chunk hashes, so an open tab 404s on
+ # /node_modules/.vite/deps/chunk-*.js ("error loading dynamically imported module").
+ - frontend_vite_cache:/app/node_modules/.vite
env_file: .env
backend-go:
@@ -438,3 +442,5 @@ volumes:
driver: local
authentik_postgres:
driver: local
+ frontend_vite_cache:
+ driver: local
diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts
index 4b85595566..bd376af6a7 100644
--- a/frontend/vite.config.ts
+++ b/frontend/vite.config.ts
@@ -66,6 +66,22 @@ export default defineConfig(({ mode }) => {
}
}
},
+ optimizeDeps: {
+ // Deps that the initial esbuild scan can't reach: `react/jsx-runtime` is injected by the
+ // SWC transform (the scanner reads pre-transform source), and the rest are only imported
+ // from lazy route components. Discovering them mid-session re-runs optimizeDeps, which
+ // rotates the ?v= hash on every /node_modules/.vite/deps URL and force-reloads the page.
+ include: [
+ "react/jsx-runtime",
+ "crypto",
+ "react-icons/bs",
+ "react-icons/di",
+ "react-icons/si",
+ "react-icons/vsc",
+ "@fortawesome/free-brands-svg-icons",
+ "@fortawesome/free-regular-svg-icons"
+ ]
+ },
experimental: {
renderBuiltUrl(filename, { hostType }) {
if (hostType === "js") {