mirror of
https://github.com/makeplane/plane.git
synced 2025-12-15 19:37:51 +01:00
60 lines
1.9 KiB
TypeScript
60 lines
1.9 KiB
TypeScript
import path from "node:path";
|
|
import { reactRouter } from "@react-router/dev/vite";
|
|
import { defineConfig } from "vite";
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
import { joinUrlPath } from "@plane/utils";
|
|
|
|
const PUBLIC_ENV_KEYS = [
|
|
"NEXT_PUBLIC_API_BASE_URL",
|
|
"NEXT_PUBLIC_API_BASE_PATH",
|
|
"NEXT_PUBLIC_ADMIN_BASE_URL",
|
|
"NEXT_PUBLIC_ADMIN_BASE_PATH",
|
|
"NEXT_PUBLIC_SPACE_BASE_URL",
|
|
"NEXT_PUBLIC_SPACE_BASE_PATH",
|
|
"NEXT_PUBLIC_LIVE_BASE_URL",
|
|
"NEXT_PUBLIC_LIVE_BASE_PATH",
|
|
"NEXT_PUBLIC_WEB_BASE_URL",
|
|
"NEXT_PUBLIC_WEB_BASE_PATH",
|
|
"NEXT_PUBLIC_WEBSITE_URL",
|
|
"NEXT_PUBLIC_SUPPORT_EMAIL",
|
|
];
|
|
|
|
const publicEnv = PUBLIC_ENV_KEYS.reduce<Record<string, string>>((acc, key) => {
|
|
acc[key] = process.env[key] ?? "";
|
|
return acc;
|
|
}, {});
|
|
|
|
export default defineConfig(({ isSsrBuild }) => {
|
|
// Only produce an SSR bundle when explicitly enabled.
|
|
// For static deployments (default), we skip the server build entirely.
|
|
const enableSsrBuild = process.env.ADMIN_ENABLE_SSR_BUILD === "true";
|
|
const basePath = joinUrlPath(process.env.NEXT_PUBLIC_ADMIN_BASE_PATH ?? "", "/") ?? "/";
|
|
|
|
return {
|
|
base: basePath,
|
|
define: {
|
|
"process.env": JSON.stringify(publicEnv),
|
|
},
|
|
build: {
|
|
assetsInlineLimit: 0,
|
|
rollupOptions:
|
|
isSsrBuild && enableSsrBuild
|
|
? {
|
|
input: path.resolve(__dirname, "server/app.ts"),
|
|
}
|
|
: undefined,
|
|
},
|
|
plugins: [reactRouter(), tsconfigPaths({ projects: [path.resolve(__dirname, "tsconfig.json")] })],
|
|
resolve: {
|
|
alias: {
|
|
// Next.js compatibility shims used within admin
|
|
"next/image": path.resolve(__dirname, "app/compat/next/image.tsx"),
|
|
"next/link": path.resolve(__dirname, "app/compat/next/link.tsx"),
|
|
"next/navigation": path.resolve(__dirname, "app/compat/next/navigation.ts"),
|
|
},
|
|
dedupe: ["react", "react-dom"],
|
|
},
|
|
// No SSR-specific overrides needed; alias resolves to ESM build
|
|
};
|
|
});
|