import react from "@vitejs/plugin-react"; import { defineConfig, type UserConfig } from "vite"; export const commonViteConfig: UserConfig = { plugins: [react()], // Since we are using pnpm and common is our root, we might not need the strict aliases // for react and lucide-react anymore, as pnpm will resolve them correctly from the root node_modules. // If we do need them, we can add them back per-app or dynamically resolve from common's __dirname. build: { emptyOutDir: true, }, }; export function hostFromUrl(value: string | undefined) { if (!value) return undefined; try { return new URL(value).hostname; } catch { return value; } } export function getAllowedHosts( defaultHosts: string[], envUrl?: string, envAllowedHosts?: string ) { return Array.from( new Set( [ ...defaultHosts, hostFromUrl(envUrl), ...(envAllowedHosts ?? "") .split(",") .map((host) => host.trim()) .filter(Boolean), ].filter((host): host is string => Boolean(host)) ) ); } export default defineConfig(commonViteConfig);