2026-03-22 15:36:17 +05:45
|
|
|
import { defineConfig, loadEnv } from "vite";
|
2025-01-01 00:00:00 +00:00
|
|
|
import react from "@vitejs/plugin-react-swc";
|
|
|
|
|
import path from "path";
|
|
|
|
|
import { componentTagger } from "lovable-tagger";
|
|
|
|
|
|
2026-03-22 15:36:17 +05:45
|
|
|
export default defineConfig(({ mode }) => {
|
|
|
|
|
const env = loadEnv(mode, process.cwd(), "");
|
|
|
|
|
|
2026-04-26 16:47:48 +09:30
|
|
|
const themeName = env.VITE_THEME || "default";
|
|
|
|
|
const themeColors: Record<string, { primary: string; sidebarPrimary: string; ring: string }> = {
|
|
|
|
|
default: { primary: "173 65% 36%", sidebarPrimary: "173 65% 36%", ring: "173 65% 36%" },
|
|
|
|
|
dev: { primary: "0 72% 51%", sidebarPrimary: "0 72% 51%", ring: "0 72% 51%" },
|
|
|
|
|
preprod: { primary: "270 70% 55%", sidebarPrimary: "270 70% 55%", ring: "270 70% 55%" },
|
|
|
|
|
};
|
|
|
|
|
const colors = themeColors[themeName] || themeColors.default;
|
|
|
|
|
|
|
|
|
|
const appName = env.VITE_APP_NAME || (themeName === "dev" ? "Secuird Dev" : themeName === "preprod" ? "Secuird Staging" : "Secuird");
|
|
|
|
|
const favicon = env.VITE_FAVICON || (themeName === "dev" ? "/favicon-dev.svg" : themeName === "preprod" ? "/favicon-staging.svg" : "/favicon.svg");
|
|
|
|
|
|
2026-04-26 17:35:49 +09:30
|
|
|
const themeColorHsl = `hsl(${colors.primary})`;
|
|
|
|
|
|
|
|
|
|
// Build a CSS block that injects directly into <head> before any stylesheets load.
|
|
|
|
|
const themeStyles = `
|
|
|
|
|
<style data-theme="${themeName}">
|
|
|
|
|
:root {
|
|
|
|
|
--theme-primary: ${colors.primary};
|
|
|
|
|
--theme-primary-foreground: 0 0% 100%;
|
|
|
|
|
--theme-sidebar-primary: ${colors.sidebarPrimary};
|
|
|
|
|
--theme-sidebar-primary-foreground: 0 0% 100%;
|
|
|
|
|
--theme-ring: ${colors.ring};
|
|
|
|
|
--theme-color: ${themeColorHsl};
|
|
|
|
|
}
|
|
|
|
|
</style>`;
|
2026-04-26 16:47:48 +09:30
|
|
|
|
2026-03-22 15:36:17 +05:45
|
|
|
return {
|
|
|
|
|
server: {
|
|
|
|
|
host: "::",
|
|
|
|
|
port: 8080,
|
|
|
|
|
allowedHosts: env.VITE_ALLOWED_HOSTS?.split(",") || [
|
|
|
|
|
"ui.webauthn.local",
|
|
|
|
|
"gatehouse-ui.hawkvelt.tech",
|
|
|
|
|
],
|
|
|
|
|
},
|
2026-04-26 16:47:48 +09:30
|
|
|
plugins: [
|
|
|
|
|
react(),
|
|
|
|
|
mode === "development" && componentTagger(),
|
|
|
|
|
{
|
|
|
|
|
name: "vite-plugin-theme-injection",
|
|
|
|
|
transformIndexHtml: {
|
|
|
|
|
order: "pre",
|
|
|
|
|
handler: (html) => {
|
2026-04-26 17:35:49 +09:30
|
|
|
const headClose = html.indexOf("</head>");
|
|
|
|
|
const withStyle = headClose > -1
|
|
|
|
|
? html.slice(0, headClose) + themeStyles + "\n" + html.slice(headClose)
|
|
|
|
|
: html;
|
|
|
|
|
return withStyle
|
2026-04-26 16:47:48 +09:30
|
|
|
.replace(/%VITE_APP_NAME%/g, appName)
|
|
|
|
|
.replace(/%VITE_FAVICON%/g, favicon)
|
2026-04-26 17:35:49 +09:30
|
|
|
.replace(/%VITE_THEME_COLOR%/g, themeColorHsl);
|
2026-04-26 16:47:48 +09:30
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
},
|
|
|
|
|
],
|
2026-03-22 15:36:17 +05:45
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
"@": path.resolve(__dirname, "./src"),
|
|
|
|
|
},
|
2025-01-01 00:00:00 +00:00
|
|
|
},
|
2026-04-26 07:06:34 +00:00
|
|
|
build: {
|
|
|
|
|
target: "esnext",
|
|
|
|
|
},
|
2026-03-22 15:36:17 +05:45
|
|
|
};
|
|
|
|
|
});
|