🤯 LobeHub - Super-Agents on Your Team. Add super-agents to the chats your team already uses.They take on work by themselves and get better every week.
TypeScript agentagent-collaborationagent-harnessloop-engineeringmcppersonal-assistantproactive-agentskillssuper-agenttask-management
♻️ refactor: serve Vite SPA static assets under /_spa (#13409)
Inneif6314cc67365
diff --git a/.gitignore b/.gitignoreindex c39d230e65a..66d0ac8479d 100644--- a/.gitignore+++ b/.gitignore@@ -52,6 +52,7 @@ bun.lockb# Build outputsdist/+public/_spa/public/spa/es/lib/diff --git a/Dockerfile b/Dockerfileindex 9466d0614d3..534b64337c3 100644--- a/Dockerfile+++ b/Dockerfile@@ -111,7 +111,7 @@ COPY --from=base /distroless/ /COPY --from=builder /app/.next/standalone /app/COPY --from=builder /app/.next/static /app/.next/static# Copy SPA assets (Vite build output)-COPY --from=builder /app/public/spa /app/public/spa+COPY --from=builder /app/public/_spa /app/public/_spa# Copy database migrationsCOPY --from=builder /app/packages/database/migrations /app/migrationsCOPY --from=builder /app/scripts/migrateServerDB/docker.cjs /app/docker.cjsdiff --git a/next.config.ts b/next.config.tsindex 1b6ab2fcd15..77b9fa022eb 100644--- a/next.config.ts+++ b/next.config.ts@@ -11,7 +11,7 @@ const vercelConfig = {'node_modules/.pnpm/@napi-rs+canvas-*-musl*','node_modules/.pnpm/@img+sharp-libvips-*musl*',// Exclude SPA/desktop/mobile build artifacts from serverless functions- 'public/spa/**',+ 'public/_spa/**','dist/desktop/**','dist/mobile/**','apps/desktop/**',diff --git a/package.json b/package.jsonindex 71b63dfb016..105a88da961 100644--- a/package.json+++ b/package.json@@ -43,7 +43,7 @@"build:spa": "cross-env NODE_OPTIONS=--max-old-space-size=7168 pnpm run build:spa:raw","build:spa:copy": "tsx scripts/copySpaBuild.mts && tsx scripts/generateSpaTemplates.mts","build:spa:mobile": "cross-env NODE_OPTIONS=--max-old-space-size=8192 MOBILE=true vite build",- "build:spa:raw": "rm -rf public/spa && vite build",+ "build:spa:raw": "rm -rf public/_spa && vite build","build:vercel": "cross-env-shell NODE_OPTIONS=--max-old-space-size=6144 \"bun run build:raw && bun run db:migrate\"","build-migrate-db": "bun run db:migrate","build-sitemap": "tsx ./scripts/buildSitemapIndex/index.ts",diff --git a/scripts/copySpaBuild.mts b/scripts/copySpaBuild.mtsindex a883c256b41..aabd6c49902 100644--- a/scripts/copySpaBuild.mts+++ b/scripts/copySpaBuild.mts@@ -2,7 +2,7 @@ import { cpSync, existsSync, mkdirSync } from 'node:fs';import path from 'node:path';const root = path.resolve(import.meta.dirname, '..');-const spaDir = path.resolve(root, 'public/spa');+const spaDir = path.resolve(root, 'public/_spa');const distDirs = ['desktop', 'mobile'] as const;const copyDirs = ['assets', 'i18n', 'vendor'] as const;@@ -16,6 +16,6 @@ for (const distDir of distDirs) {if (!existsSync(sourceDir)) continue;cpSync(sourceDir, targetDir, { recursive: true });- console.log(`Copied dist/${distDir}/${dir} -> public/spa/${dir}`);+ console.log(`Copied dist/${distDir}/${dir} -> public/_spa/${dir}`);}}diff --git a/src/libs/next/config/define-config.ts b/src/libs/next/config/define-config.tsindex 4e5698ff550..48c0a7d897d 100644--- a/src/libs/next/config/define-config.ts+++ b/src/libs/next/config/define-config.ts@@ -36,7 +36,7 @@ export function defineConfig(config: CustomNextConfig) {...(buildWithDocker? [// Exclude SPA/desktop/mobile build artifacts from serverless functions- 'public/spa/**',+ 'public/_spa/**','dist/desktop/**','dist/mobile/**',diff --git a/src/libs/pdfjs/index.tsx b/src/libs/pdfjs/index.tsxindex 3b2c3430e67..232cfc2f7d5 100644--- a/src/libs/pdfjs/index.tsx+++ b/src/libs/pdfjs/index.tsx@@ -1,6 +1,6 @@'use client';-// Use Vite's ?url import to get the correct hashed asset path (e.g. /spa/assets/pdf.worker-xxx.mjs)+// Use Vite's ?url import to get the correct hashed asset path (e.g. /_spa/assets/pdf.worker-xxx.mjs)// This overrides react-pdf's auto-detected bare filename which breaks under SPA routing.import pdfjsWorkerUrl from 'pdfjs-dist/build/pdf.worker.min.mjs?url';import { type ComponentProps } from 'react';diff --git a/vercel.json b/vercel.jsonindex 06953d1c83f..daf2d1e4113 100644--- a/vercel.json+++ b/vercel.json@@ -2,7 +2,7 @@"buildCommand": "bun run build:vercel","headers": [{- "source": "/spa/assets/(.*)",+ "source": "/_spa/(.*)","headers": [{"key": "Cache-Control",diff --git a/vite.config.ts b/vite.config.tsindex 687d71ebd4a..3085c7a81a8 100644--- a/vite.config.ts+++ b/vite.config.ts@@ -22,7 +22,7 @@ const isDev = process.env.NODE_ENV !== 'production';const platform = isMobile ? 'mobile' : 'web';export default defineConfig({- base: isDev ? '/' : process.env.VITE_CDN_BASE || '/spa/',+ base: isDev ? '/' : process.env.VITE_CDN_BASE || '/_spa/',build: {outDir: isMobile ? 'dist/mobile' : 'dist/desktop',rollupOptions: {