mirror of
https://github.com/Tria-plc/edr-platform.git
synced 2026-09-09 10:58:14 +00:00
Add TypeScript type annotations to Vite config and dedupe Mantine dependencies
This commit is contained in:
@@ -1,23 +1,35 @@
|
|||||||
import path from "node:path";
|
import path from "node:path";
|
||||||
import { fileURLToPath } from "node:url";
|
import { fileURLToPath } from "node:url";
|
||||||
|
import type { IncomingMessage, ServerResponse } from "node:http";
|
||||||
|
|
||||||
/// <reference types="vitest/config" />
|
import { defineConfig } from "vitest/config";
|
||||||
import { defineConfig } from "vite";
|
|
||||||
import react from "@vitejs/plugin-react";
|
import react from "@vitejs/plugin-react";
|
||||||
import tailwindcss from "@tailwindcss/vite";
|
import tailwindcss from "@tailwindcss/vite";
|
||||||
|
import type { ViteDevServer, PreviewServer } from "vite";
|
||||||
|
|
||||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||||
|
|
||||||
function userManagementSpaFallback() {
|
function userManagementSpaFallback() {
|
||||||
const rewrite = (req) => {
|
const rewrite = (req: IncomingMessage) => {
|
||||||
const url = req.url || '';
|
const url = req.url ?? '';
|
||||||
if (!url.startsWith('/_um/') && url !== '/_um') return;
|
if (!url.startsWith('/_um/') && url !== '/_um') return;
|
||||||
if (/\.[a-zA-Z0-9]+$/.test(url.split('?')[0])) return;
|
if (/\.[a-zA-Z0-9]+$/.test(url.split('?')[0])) return;
|
||||||
req.url = '/_um/index.html';
|
req.url = '/_um/index.html';
|
||||||
};
|
};
|
||||||
return {
|
return {
|
||||||
name: 'user-management-spa-fallback',
|
name: 'user-management-spa-fallback',
|
||||||
configureServer(s){ s.middlewares.use((req,_r,next)=>{rewrite(req);next();}); },
|
configureServer(s: ViteDevServer) {
|
||||||
configurePreviewServer(s){ s.middlewares.use((req,_r,next)=>{rewrite(req);next();}); },
|
s.middlewares.use((req: IncomingMessage, _r: ServerResponse, next: () => void) => {
|
||||||
|
rewrite(req);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
},
|
||||||
|
configurePreviewServer(s: PreviewServer) {
|
||||||
|
s.middlewares.use((req: IncomingMessage, _r: ServerResponse, next: () => void) => {
|
||||||
|
rewrite(req);
|
||||||
|
next();
|
||||||
|
});
|
||||||
|
},
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -29,6 +41,11 @@ export default defineConfig({
|
|||||||
// 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"),
|
||||||
},
|
},
|
||||||
|
// Force a single copy of these singletons so MantineProvider context is
|
||||||
|
// shared between the backoffice 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"],
|
||||||
},
|
},
|
||||||
server: {
|
server: {
|
||||||
port: 5183,
|
port: 5183,
|
||||||
|
|||||||
@@ -137,7 +137,7 @@ export interface ConfirmPaymentRequest {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Response of `POST /payments/initiate` and shape of intent lookups. */
|
/** Response of `POST /payments/initiate` and shape of intent lookups. */
|
||||||
export interface PaymentIntentSnapshot {
|
export type PaymentIntentSnapshot ={
|
||||||
intentId: string;
|
intentId: string;
|
||||||
service: PaymentService;
|
service: PaymentService;
|
||||||
referenceType: PaymentReferenceType;
|
referenceType: PaymentReferenceType;
|
||||||
|
|||||||
Reference in New Issue
Block a user