mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-08-30 12:18:11 +00:00
Pin Mantine dependencies to portal's node_modules and optimize dependency pre-bundling to prevent React version conflicts
This commit is contained in:
@@ -23,6 +23,7 @@ function userManagementSpaFallback() {
|
|||||||
rewrite(req);
|
rewrite(req);
|
||||||
next();
|
next();
|
||||||
});
|
});
|
||||||
|
|
||||||
},
|
},
|
||||||
configurePreviewServer(s: PreviewServer) {
|
configurePreviewServer(s: PreviewServer) {
|
||||||
s.middlewares.use((req: IncomingMessage, _r: ServerResponse, next: () => void) => {
|
s.middlewares.use((req: IncomingMessage, _r: ServerResponse, next: () => void) => {
|
||||||
|
|||||||
@@ -7,6 +7,12 @@ import tailwindcss from "@tailwindcss/vite";
|
|||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
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({
|
export default defineConfig({
|
||||||
plugins: [react(), tailwindcss()],
|
plugins: [react(), tailwindcss()],
|
||||||
resolve: {
|
resolve: {
|
||||||
@@ -14,13 +20,14 @@ export default defineConfig({
|
|||||||
"@": path.resolve(__dirname, "./src"),
|
"@": path.resolve(__dirname, "./src"),
|
||||||
// Resolve from TS source so Vite gets ESM named exports (dist is CommonJS).
|
// Resolve from TS source so Vite gets ESM named exports (dist is CommonJS).
|
||||||
"@edr/types": path.resolve(__dirname, "../../../packages/types/src/index.ts"),
|
"@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"],
|
dedupe: ["react", "react-dom", "@mantine/core", "@mantine/hooks"],
|
||||||
},
|
},
|
||||||
|
optimizeDeps: {
|
||||||
|
include: ["@mantine/core", "@mantine/hooks", "@edr/ui-common"],
|
||||||
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 5173,
|
port: 5173,
|
||||||
host: "0.0.0.0",
|
host: "0.0.0.0",
|
||||||
|
|||||||
Reference in New Issue
Block a user