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,80 +1,43 @@
|
||||
import react from "@vitejs/plugin-react";
|
||||
import path from "node:path";
|
||||
import { defineConfig } from "vite";
|
||||
import { defineConfig, mergeConfig } from "vite";
|
||||
import { commonViteConfig, getAllowedHosts } from "../common/config/vite.base";
|
||||
|
||||
const buildOutDir =
|
||||
process.env.DEVFRONT_BUILD_OUT_DIR ?? "/tmp/baron-sso-devfront-dist";
|
||||
|
||||
const defaultAllowedHosts = [
|
||||
"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.DEVFRONT_URL),
|
||||
...(process.env.DEVFRONT_ALLOWED_HOSTS ?? "")
|
||||
.split(",")
|
||||
.map((host) => host.trim())
|
||||
.filter(Boolean),
|
||||
].filter((host): host is string => Boolean(host)),
|
||||
),
|
||||
const allowedHosts = getAllowedHosts(
|
||||
["sdev.hmac.kr", "localhost", "172.16.10.176", "127.0.0.1"],
|
||||
process.env.DEVFRONT_URL,
|
||||
process.env.DEVFRONT_ALLOWED_HOSTS
|
||||
);
|
||||
|
||||
export default defineConfig({
|
||||
plugins: [react()],
|
||||
resolve: {
|
||||
alias: {
|
||||
"lucide-react": path.resolve(__dirname, "node_modules/lucide-react"),
|
||||
react: path.resolve(__dirname, "node_modules/react"),
|
||||
"react/jsx-dev-runtime": path.resolve(
|
||||
__dirname,
|
||||
"node_modules/react/jsx-dev-runtime.js",
|
||||
),
|
||||
"react/jsx-runtime": path.resolve(
|
||||
__dirname,
|
||||
"node_modules/react/jsx-runtime.js",
|
||||
),
|
||||
export default defineConfig(
|
||||
mergeConfig(commonViteConfig, {
|
||||
cacheDir:
|
||||
process.env.DEVFRONT_VITE_CACHE_DIR ??
|
||||
"/tmp/baron-sso-devfront-vite-cache",
|
||||
build: {
|
||||
outDir: buildOutDir,
|
||||
},
|
||||
},
|
||||
cacheDir:
|
||||
process.env.DEVFRONT_VITE_CACHE_DIR ?? "/tmp/baron-sso-devfront-vite-cache",
|
||||
build: {
|
||||
outDir: buildOutDir,
|
||||
emptyOutDir: true,
|
||||
},
|
||||
server: {
|
||||
host: "127.0.0.1",
|
||||
allowedHosts,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.API_PROXY_TARGET || "http://localhost:3000",
|
||||
changeOrigin: true,
|
||||
server: {
|
||||
host: "127.0.0.1",
|
||||
allowedHosts,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.API_PROXY_TARGET || "http://localhost:3000",
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
preview: {
|
||||
host: "127.0.0.1",
|
||||
port: 5173,
|
||||
allowedHosts,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.API_PROXY_TARGET || "http://localhost:3000",
|
||||
changeOrigin: true,
|
||||
preview: {
|
||||
host: "127.0.0.1",
|
||||
port: 5173,
|
||||
allowedHosts,
|
||||
proxy: {
|
||||
"/api": {
|
||||
target: process.env.API_PROXY_TARGET || "http://localhost:3000",
|
||||
changeOrigin: true,
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
});
|
||||
})
|
||||
);
|
||||
|
||||
Reference in New Issue
Block a user