2025-11-06 13:58:24 +05:30
|
|
|
import path from "node:path";
|
|
|
|
|
import { reactRouter } from "@react-router/dev/vite";
|
2025-11-11 14:08:42 +05:30
|
|
|
import dotenv from "dotenv";
|
2025-11-06 13:58:24 +05:30
|
|
|
import { defineConfig } from "vite";
|
|
|
|
|
import tsconfigPaths from "vite-tsconfig-paths";
|
|
|
|
|
import { joinUrlPath } from "@plane/utils";
|
|
|
|
|
|
2025-11-11 14:08:42 +05:30
|
|
|
dotenv.config({ path: path.resolve(__dirname, ".env") });
|
2025-11-06 13:58:24 +05:30
|
|
|
|
2025-11-11 14:08:42 +05:30
|
|
|
// Automatically expose all environment variables prefixed with NEXT_PUBLIC_
|
|
|
|
|
const publicEnv = Object.keys(process.env)
|
|
|
|
|
.filter((key) => key.startsWith("NEXT_PUBLIC_"))
|
|
|
|
|
.reduce<Record<string, string>>((acc, key) => {
|
|
|
|
|
acc[key] = process.env[key] ?? "";
|
|
|
|
|
return acc;
|
|
|
|
|
}, {});
|
2025-11-06 13:58:24 +05:30
|
|
|
|
2025-11-11 14:08:42 +05:30
|
|
|
const basePath = joinUrlPath(process.env.NEXT_PUBLIC_SPACE_BASE_PATH ?? "", "/") ?? "/";
|
2025-11-06 13:58:24 +05:30
|
|
|
|
2025-11-11 14:08:42 +05:30
|
|
|
export default defineConfig(() => ({
|
|
|
|
|
base: basePath,
|
|
|
|
|
define: {
|
|
|
|
|
"process.env": JSON.stringify(publicEnv),
|
|
|
|
|
},
|
|
|
|
|
build: {
|
|
|
|
|
assetsInlineLimit: 0,
|
|
|
|
|
},
|
|
|
|
|
plugins: [reactRouter(), tsconfigPaths({ projects: [path.resolve(__dirname, "tsconfig.json")] })],
|
|
|
|
|
resolve: {
|
|
|
|
|
alias: {
|
|
|
|
|
// Next.js compatibility shims used within space
|
|
|
|
|
"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"),
|
2025-11-06 13:58:24 +05:30
|
|
|
},
|
2025-11-11 14:08:42 +05:30
|
|
|
dedupe: ["react", "react-dom"],
|
|
|
|
|
},
|
|
|
|
|
}));
|