From b83b6f28d6b1a2781cbcb7beb64762223dfe6f25 Mon Sep 17 00:00:00 2001 From: David Montero Crespo Date: Fri, 8 May 2026 01:18:31 -0300 Subject: [PATCH] fix(vite): only preserveSymlinks during dev, not build MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Previous commit unconditionally enabled preserveSymlinks when VITE_PRO_BUILD was set. That works for `vite dev` (where the overlay is wired in via a Windows junction and the resolver needs to keep the junction path so relative imports back into the OSS sibling dirs resolve), but it BREAKS `vite build` in Docker — there are no symlinks to preserve, and Rollup with preserveSymlinks=true fails to resolve relative imports from the copied overlay tree: Could not resolve "../../../services/componentRegistry" from "src/pro/agent/tools/canvas.ts" Gate the flag on `command === 'serve'` so it only kicks in during dev. Production builds always run with preserveSymlinks=false (the default). Co-Authored-By: Claude Opus 4.7 (1M context) --- frontend/vite.config.ts | 22 ++++++++++++++-------- 1 file changed, 14 insertions(+), 8 deletions(-) diff --git a/frontend/vite.config.ts b/frontend/vite.config.ts index d9c50f2a..80b647be 100644 --- a/frontend/vite.config.ts +++ b/frontend/vite.config.ts @@ -15,18 +15,24 @@ const proOverlayPath = ? path.resolve(process.env.PRO_OVERLAY_PATH) : path.resolve(__dirname, 'src/__pro_stub__') -export default defineConfig({ +export default defineConfig(({ command }) => ({ plugins: [react()], resolve: { alias: { '@pro': proOverlayPath, }, - // When the pro overlay is wired in via a junction (Windows local-dev - // pattern), Vite's default resolution walks symlinks to the real path, - // which breaks relative imports from pro into upstream sibling dirs. - // Keeping the symlink-as-path lets `../../store/...` from pro resolve - // back into the OSS tree's src/. - preserveSymlinks: !!process.env.VITE_PRO_BUILD, + // Local dev only: when the pro overlay is wired in via a junction + // (Windows pattern: `frontend/src/pro` → `velxio-prod/pro/frontend/src/pro`), + // Vite's default resolver walks symlinks to the real path, which breaks + // relative imports like `../../store/...` from inside the overlay back + // into the OSS sibling dirs. Keeping the symlink-as-path fixes that. + // + // We do NOT enable this during `vite build` (Docker / CI): production + // builds COPY the overlay tree into the OSS frontend so there are no + // symlinks involved, and turning preserveSymlinks on there breaks + // Rollup's resolution of relative imports across the overlay/upstream + // boundary (real bug observed in Dockerfile.prod stage 1). + preserveSymlinks: command === 'serve' && !!process.env.VITE_PRO_BUILD, }, server: { proxy: { @@ -50,4 +56,4 @@ export default defineConfig({ reporter: ['text', 'html'], }, }, -}) +}))