1
0
forked from baron/baron-sso
Files
baron-sso/common/config/vite.base.ts
chan 8951de510e refactor(frontend): centralize configurations and deduplicate dependencies in common workspace
- Centralized biome.json, tailwind.config.ts, and vite.config.ts into common/config.
- Updated sub-apps to inherit from shared base configurations.
- Deduplicated dependencies across apps using common workspace.
- Fixed TypeScript resolution issues by restoring necessary build dependencies.
- Removed obsolete package-lock.json files.
- Applied minor import fixes via Biome.
- Fixed react-router-dom v7 type errors.
2026-05-15 10:28:07 +09:00

43 lines
1.1 KiB
TypeScript

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);