🤯 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(desktop): stop bundling web SPA artifacts into the renderer dist (#18644)
Innei1bd6c6c56c84
diff --git a/apps/desktop/vite.renderer.config.ts b/apps/desktop/vite.renderer.config.tsindex 1c13f632377..f0a6f72b0ee 100644--- a/apps/desktop/vite.renderer.config.ts+++ b/apps/desktop/vite.renderer.config.ts@@ -15,6 +15,7 @@ import {sharedRendererDefine,sharedRendererPlugins,} from '../../plugins/vite/sharedRendererConfig';+import { spaPublicDirNames } from '../../scripts/copySpaBuildCore';import {applyDesktopViteConfigExtension,CLOUD_ROOT_DIR,@@ -28,18 +29,19 @@ import {} from './vite.shared';const RENDERER_OUT_DIR = path.resolve(__dirname, 'dist/renderer');-const WEB_SPA_BUILD_DIRECTORIES = ['_spa', '_spa-auth'];/*** The repository public directory can contain ignored web build outputs after* local SPA builds. Vite copies the whole directory by default, so remove only* those generated web outputs from the generated desktop renderer directory.+ * The directory list is derived from the copy script's targets so a newly+ * added SPA surface cannot silently ride into the desktop bundle again.*/function excludeWebSpaBuildArtifactsPlugin(): PluginOption {return {async closeBundle() {await Promise.all(- WEB_SPA_BUILD_DIRECTORIES.map((directory) =>+ spaPublicDirNames.map((directory) =>rm(path.join(RENDERER_OUT_DIR, directory), { force: true, recursive: true }),),);diff --git a/scripts/copySpaBuild.test.ts b/scripts/copySpaBuild.test.tsindex 647d20c8313..fcfd098ae2c 100644--- a/scripts/copySpaBuild.test.ts+++ b/scripts/copySpaBuild.test.ts@@ -5,7 +5,7 @@ import path from 'node:path';import { afterEach, describe, expect, it } from 'vitest';-import { copySpaBuild } from './copySpaBuildCore';+import { copySpaBuild, spaPublicDirNames } from './copySpaBuildCore';const testRoots: string[] = [];@@ -67,6 +67,16 @@ describe('copySpaBuild', () => {expect(existsSync(path.join(root, 'public/_spa/model-bank/catalog.js'))).toBe(true);});+ // The desktop renderer build copies the repo `public/` wholesale and prunes+ // these directories afterwards; a target whose publicDir escapes this list+ // ships its whole SPA inside the Electron asar.+ it('derives a public dir name for every copy target', () => {+ expect(spaPublicDirNames.sort()).toEqual(['_spa', '_spa-auth', '_spa-share', '_spa-workbench']);+ for (const name of spaPublicDirNames) {+ expect(name).toMatch(/^_spa/);+ }+ });+it('publishes Workbench chunks under an isolated public asset root', () => {const root = mkdtempSync(path.join(tmpdir(), 'copy-spa-workbench-'));testRoots.push(root);diff --git a/scripts/copySpaBuildCore.ts b/scripts/copySpaBuildCore.tsindex c379f7ca4ee..a3f646bcf12 100644--- a/scripts/copySpaBuildCore.ts+++ b/scripts/copySpaBuildCore.ts@@ -17,6 +17,10 @@ const targets = [{ distDir: 'share', publicDir: 'public/_spa-share' },] as const;+export const spaPublicDirNames = [+ ...new Set(targets.map(({ publicDir }) => publicDir.split('/')[1])),+];+export const copySpaBuild = (root = path.resolve(import.meta.dirname, '..')) => {for (const { distDir, publicDir } of targets) {const distRoot = path.resolve(root, `dist/${distDir}`);