forked from baron/baron-sso
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.
This commit is contained in:
@@ -1,68 +1,51 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, mergeConfig } from "vite";
|
||||
import { commonViteConfig, getAllowedHosts } from "../common/config/vite.base";
|
||||
|
||||
const buildOutDir =
|
||||
process.env.ORGFRONT_BUILD_OUT_DIR ?? "/tmp/baron-sso-orgfront-dist";
|
||||
|
||||
const defaultAllowedHosts = [
|
||||
"baron-orgchart.hmac.kr",
|
||||
"sorg.hmac.kr",
|
||||
"sdev.hmac.kr",
|
||||
"localhost",
|
||||
"172.16.10.176",
|
||||
"127.0.0.1",
|
||||
];
|
||||
|
||||
function hostFromUrl(value: string | undefined) {
|
||||
if (!value) return undefined;
|
||||
try {
|
||||
return new URL(value).hostname;
|
||||
} catch {
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
const allowedHosts = Array.from(
|
||||
new Set(
|
||||
[
|
||||
...defaultAllowedHosts,
|
||||
hostFromUrl(process.env.ORGFRONT_URL),
|
||||
...(process.env.ORGFRONT_ALLOWED_HOSTS ?? "")
|
||||
.split(",")
|
||||
.map((host) => host.trim())
|
||||
.filter(Boolean),
|
||||
].filter((host): host is string => Boolean(host)),
|
||||
),
|
||||
const allowedHosts = getAllowedHosts(
|
||||
[
|
||||
"baron-orgchart.hmac.kr",
|
||||
"sorg.hmac.kr",
|
||||
"sdev.hmac.kr",
|
||||
"localhost",
|
||||
"172.16.10.176",
|
||||
"127.0.0.1",
|
||||
],
|
||||
process.env.ORGFRONT_URL,
|
||||
process.env.ORGFRONT_ALLOWED_HOSTS
|
||||
);
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
cacheDir:
|
||||
process.env.ORGFRONT_VITE_CACHE_DIR ?? "/tmp/baron-sso-orgfront-vite-cache",
|
||||
build: {
|
||||
outDir: buildOutDir,
|
||||
emptyOutDir: true,
|
||||
},
|
||||
server: {
|
||||
host: "0.0.0.0",
|
||||
port: 5175,
|
||||
allowedHosts,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.API_PROXY_TARGET || "http://localhost:5000",
|
||||
changeOrigin: true,
|
||||
export default defineConfig(
|
||||
mergeConfig(commonViteConfig, {
|
||||
cacheDir:
|
||||
process.env.ORGFRONT_VITE_CACHE_DIR ??
|
||||
"/tmp/baron-sso-orgfront-vite-cache",
|
||||
build: {
|
||||
outDir: buildOutDir,
|
||||
},
|
||||
server: {
|
||||
host: "0.0.0.0",
|
||||
port: 5175,
|
||||
allowedHosts,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.API_PROXY_TARGET || "http://localhost:5000",
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
preview: {
|
||||
host: "0.0.0.0",
|
||||
port: 5175,
|
||||
allowedHosts,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.API_PROXY_TARGET || "http://localhost:5000",
|
||||
changeOrigin: true,
|
||||
preview: {
|
||||
host: "0.0.0.0",
|
||||
port: 5175,
|
||||
allowedHosts,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.API_PROXY_TARGET || "http://localhost:5000",
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user