🤯 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
🐛 fix(auth-spa): clean stale SPA assets before auth build (#16310)
Innei872604cc6a0f
diff --git a/package.json b/package.jsonindex 2df8335730a..6a2f209936a 100644--- a/package.json+++ b/package.json@@ -46,7 +46,7 @@"build:next:raw": "next build","build:raw": "bun run build:spa:raw && bun run build:spa:auth && bun run build:spa:copy && bun run build:next:raw","build:spa": "cross-env NODE_OPTIONS=--max-old-space-size=8192 pnpm run build:spa:raw",- "build:spa:auth": "rm -rf public/_spa-auth && cross-env NODE_OPTIONS=--max-old-space-size=8192 AUTH=true vite build",+ "build:spa:auth": "rm -rf public/_spa public/_spa-auth && cross-env NODE_OPTIONS=--max-old-space-size=8192 AUTH=true vite build","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",diff --git a/scripts/copySpaBuild.mts b/scripts/copySpaBuild.mtsindex 71c3a92451c..e1e7748e755 100644--- a/scripts/copySpaBuild.mts+++ b/scripts/copySpaBuild.mts@@ -1,8 +1,9 @@-import { cpSync, existsSync, mkdirSync } from 'node:fs';+import { cpSync, existsSync, mkdirSync, readdirSync, statSync } from 'node:fs';import path from 'node:path';const root = path.resolve(import.meta.dirname, '..');const copyDirs = ['assets', 'i18n', 'vendor'] as const;+const copyRootFilePatterns = [/^favicon.*\.ico$/, /^apple-touch-icon\.png$/] as const;const targets = [{ distDir: 'desktop', publicDir: 'public/_spa' },{ distDir: 'mobile', publicDir: 'public/_spa' },@@ -10,11 +11,12 @@ const targets = [] as const;for (const { distDir, publicDir } of targets) {+ const distRoot = path.resolve(root, `dist/${distDir}`);const spaDir = path.resolve(root, publicDir);mkdirSync(spaDir, { recursive: true });for (const dir of copyDirs) {- const sourceDir = path.resolve(root, `dist/${distDir}/${dir}`);+ const sourceDir = path.resolve(distRoot, dir);const targetDir = path.resolve(spaDir, dir);if (!existsSync(sourceDir)) continue;@@ -22,4 +24,16 @@ for (const { distDir, publicDir } of targets) {cpSync(sourceDir, targetDir, { recursive: true });console.log(`Copied dist/${distDir}/${dir} -> ${publicDir}/${dir}`);}++ if (!existsSync(distRoot)) continue;++ for (const file of readdirSync(distRoot)) {+ const sourceFile = path.resolve(distRoot, file);++ if (!statSync(sourceFile).isFile()) continue;+ if (!copyRootFilePatterns.some((pattern) => pattern.test(file))) continue;++ cpSync(sourceFile, path.resolve(spaDir, file));+ console.log(`Copied dist/${distDir}/${file} -> ${publicDir}/${file}`);+ }}