diff --git a/apps/edr-freight-web/backoffice/vite.config.ts b/apps/edr-freight-web/backoffice/vite.config.ts index f5a3563a8..b6ec390a6 100644 --- a/apps/edr-freight-web/backoffice/vite.config.ts +++ b/apps/edr-freight-web/backoffice/vite.config.ts @@ -23,6 +23,7 @@ function userManagementSpaFallback() { rewrite(req); next(); }); + }, configurePreviewServer(s: PreviewServer) { s.middlewares.use((req: IncomingMessage, _r: ServerResponse, next: () => void) => { diff --git a/apps/edr-freight-web/portal/vite.config.ts b/apps/edr-freight-web/portal/vite.config.ts index 3d8023494..99e2a41d5 100644 --- a/apps/edr-freight-web/portal/vite.config.ts +++ b/apps/edr-freight-web/portal/vite.config.ts @@ -7,6 +7,12 @@ import tailwindcss from "@tailwindcss/vite"; const __dirname = path.dirname(fileURLToPath(import.meta.url)); +// Pin Mantine to this app's copy. pnpm can install a second @mantine/core under +// @edr/ui-common (linked to react@18) while the portal uses react@19 — dedupe +// alone does not merge those into one module in production builds. +const mantineCore = path.resolve(__dirname, "node_modules/@mantine/core"); +const mantineHooks = path.resolve(__dirname, "node_modules/@mantine/hooks"); + export default defineConfig({ plugins: [react(), tailwindcss()], resolve: { @@ -14,13 +20,14 @@ export default defineConfig({ "@": path.resolve(__dirname, "./src"), // Resolve from TS source so Vite gets ESM named exports (dist is CommonJS). "@edr/types": path.resolve(__dirname, "../../../packages/types/src/index.ts"), + "@mantine/core": mantineCore, + "@mantine/hooks": mantineHooks, }, - // Force a single copy of these singletons so MantineProvider context is - // shared between the portal app and @edr/ui-common (which ships its - // own node_modules copy). Without this, two separate @mantine/core - // instances are bundled and the context lookup fails at runtime. dedupe: ["react", "react-dom", "@mantine/core", "@mantine/hooks"], }, + optimizeDeps: { + include: ["@mantine/core", "@mantine/hooks", "@edr/ui-common"], + }, server: { port: 5173, host: "0.0.0.0",