Initial curated projectbrain source from 8a7b1e0651dbdab97d744cbd2e653ab3970ac6c5
This commit is contained in:
commit
5aa3e8d685
700 files changed
+132801
No files matched your search
@@ -0,0 +1,53 @@
|
||||
import { defineConfig, loadEnv, type ViteDevServer } from "vite";
|
||||
import react from "@vitejs/plugin-react";
|
||||
import path from "node:path";
|
||||
import { createB1ReadApiMiddleware } from "./src/shared/api/b1ReadBackend.ts";
|
||||
|
||||
export default defineConfig(({ command, mode }) => {
|
||||
const env = loadEnv(mode, process.cwd(), "");
|
||||
const configuredClientMode = process.env.VITE_PROJECTBRAIN_CLIENT_MODE ?? env.VITE_PROJECTBRAIN_CLIENT_MODE;
|
||||
const productionBuild = command === "build" && mode === "production";
|
||||
if (productionBuild && configuredClientMode === "mock") {
|
||||
throw new Error("Production builds cannot enable VITE_PROJECTBRAIN_CLIENT_MODE=mock.");
|
||||
}
|
||||
const realMode = configuredClientMode === "real" || (productionBuild && configuredClientMode === undefined);
|
||||
return {
|
||||
server: {
|
||||
host: "::",
|
||||
port: 8080,
|
||||
...(process.env.CI ? { watch: { usePolling: true, interval: 500 } } : {}),
|
||||
...(realMode ? { proxy: { "/api": { target: env.PROJECTBRAIN_DEV_API_TARGET || "http://127.0.0.1:4000", changeOrigin: false } } } : {}),
|
||||
},
|
||||
plugins: [
|
||||
react(),
|
||||
...(!realMode ? [{
|
||||
name: "projectbrain-b1-read-api",
|
||||
configureServer(server: ViteDevServer) {
|
||||
server.middlewares.use(createB1ReadApiMiddleware());
|
||||
},
|
||||
}] : []),
|
||||
],
|
||||
resolve: {
|
||||
alias: {
|
||||
"@": path.resolve(import.meta.dirname, "./src"),
|
||||
},
|
||||
},
|
||||
build: {
|
||||
rolldownOptions: {
|
||||
checks: { pluginTimings: false },
|
||||
output: {
|
||||
manualChunks(id) {
|
||||
if (!id.includes("node_modules")) return undefined;
|
||||
if (id.includes("react-router-dom")) return "vendor-router";
|
||||
if (id.includes("@radix-ui") || id.includes("lucide-react") || id.includes("cmdk") || id.includes("sonner")) return "vendor-ui";
|
||||
if (id.includes("recharts")) return "vendor-charts";
|
||||
if (id.includes("@tanstack/react-query")) return "vendor-query";
|
||||
if (/node_modules[\\/]\.pnpm[\\/](react|react-dom|scheduler)@/.test(id) || /node_modules[\\/](react|react-dom|scheduler)[\\/]/.test(id)) return "vendor-react";
|
||||
if (id.includes("react-day-picker") || id.includes("react-hook-form") || id.includes("react-resizable-panels")) return "vendor-forms";
|
||||
return "vendor";
|
||||
},
|
||||
},
|
||||
},
|
||||
},
|
||||
};
|
||||
});
|
||||
Reference in new issue
Block a user