Files
socaichat/langgraph/vite.config.ts
T
gongzhiyongandClaude Sonnet 4.6 569e157f25
Deploy LangGraph Server to Azure Web App / build-and-deploy (push) Failing after 29s
Deploy LangGraph UI to Azure Static Web Apps / build-and-deploy (push) Failing after 39s
fix: SPA 404 fallback + JS bundle code splitting + pre-existing build errors
- Add public/staticwebapp.config.json with navigationFallback for Azure SWA SPA routing
- Add manualChunks in vite.config.ts to split vendor deps (react/langgraph-sdk/assistant-ui/radix/markdown/charts/router)
- Add property-information resolve alias to fix refractor→hastscript@6 CJS/ESM conflict (pre-existing build failure)
- Exclude agent/ from tsconfig.app.json to fix hono missing type error (agent is backend-only, frontend CI uses pnpm vite build directly)

Build output chunks:
  vendor-react: 12.30 kB (gzip: 4.35 kB)
  vendor-langgraph: 32.85 kB (gzip: 9.29 kB)
  vendor-markdown: 316.65 kB (gzip: 94.19 kB)
  vendor-charts: 428.01 kB (gzip: 113.50 kB)
  vendor-assistant-ui: 740.11 kB (gzip: 260.11 kB)
  index: 379.74 kB (gzip: 110.17 kB)

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
2026-04-12 20:45:54 +08:00

81 lines
2.7 KiB
TypeScript

import path from "path";
import { defineConfig } from "vite";
import react from "@vitejs/plugin-react";
import tailwindcss from "@tailwindcss/vite";
// https://vite.dev/config/
export default defineConfig({
plugins: [react(), tailwindcss()],
resolve: {
alias: {
"@": path.resolve(__dirname, "./src"),
// Force refractor/hastscript@6 to use property-information@5 (CJS-compatible).
// pnpm resolves hastscript@6's transitive dep to v7 (ESM-only) at runtime,
// causing Vite's commonjs resolver to fail on the refractor→hastscript chain.
"property-information": path.resolve(
__dirname,
"node_modules/.pnpm/property-information@5.6.0/node_modules/property-information"
),
},
},
build: {
commonjsOptions: {
// Allow Rollup to transform CJS modules that import ESM-only packages
// (e.g. refractor → property-information@7 which is ESM-only)
transformMixedEsModules: true,
},
rollupOptions: {
output: {
manualChunks: {
"vendor-react": ["react", "react-dom"],
"vendor-langgraph": ["@langchain/langgraph-sdk"],
"vendor-assistant-ui": [
"@assistant-ui/react",
"@assistant-ui/react-markdown",
"@assistant-ui/react-syntax-highlighter",
],
"vendor-radix": [
"@radix-ui/react-avatar",
"@radix-ui/react-dialog",
"@radix-ui/react-label",
"@radix-ui/react-slot",
"@radix-ui/react-tooltip",
],
"vendor-markdown": [
"react-markdown",
"remark-gfm",
"remark-math",
"rehype-katex",
"katex",
],
"vendor-charts": ["recharts", "framer-motion"],
"vendor-router": ["react-router-dom"],
},
},
},
},
server: {
host: "0.0.0.0",
proxy: {
// Proxy all LangGraph API calls through Vite dev server
// so browser uses same origin (:5173) and Docker internal DNS resolves langgraph-dev
"/threads": {
target: process.env.LANGGRAPH_BACKEND_URL ?? process.env.VITE_LANGGRAPH_URL ?? "http://localhost:2024",
changeOrigin: true,
},
"/runs": {
target: process.env.LANGGRAPH_BACKEND_URL ?? process.env.VITE_LANGGRAPH_URL ?? "http://localhost:2024",
changeOrigin: true,
},
"/assistants": {
target: process.env.LANGGRAPH_BACKEND_URL ?? process.env.VITE_LANGGRAPH_URL ?? "http://localhost:2024",
changeOrigin: true,
},
"/store": {
target: process.env.LANGGRAPH_BACKEND_URL ?? process.env.VITE_LANGGRAPH_URL ?? "http://localhost:2024",
changeOrigin: true,
},
},
},
});