feat(desktop): support remote lite build mode without bundled JRE/JAR#417
Open
Joe0720 wants to merge 2 commits into
Open
feat(desktop): support remote lite build mode without bundled JRE/JAR#417Joe0720 wants to merge 2 commits into
Joe0720 wants to merge 2 commits into
Conversation
added 2 commits
June 25, 2026 17:02
Add a dual packaging mode system controlled by the BUILD_MODE env var: - **local** (default): Full build bundling JRE + Spring Boot JAR, identical to the previous behavior. Supports both embedded local backend and remote server connection. - **remote** (lite): Omits the ~530 MB JRE/JAR resources, producing an installer that is ~81% smaller (97 MB vs 523 MB on macOS arm64). The app only supports connecting to a remote server; the "local" option is hidden from the splash connection chooser. Changes: - Replace static electron-builder.json with dynamic electron-builder.cjs that conditionally includes extraResources based on BUILD_MODE - Add build mode detection at runtime (checks JAR existence) with graceful fallback to remote-only mode - Add IPC handler app:get-build-mode and expose via preload - Hide "本地运行" option in splash when running a remote build - Ignore stale 'local' saved config in remote builds - Add package scripts: package:mac:local, package:mac:remote, etc. - Add missing build scripts: build.sh, download-jre.sh, build-all-platforms.sh - Add no-op afterPack hook (trim-playwright-driver.cjs) placeholder - Add cross-env devDependency for cross-platform BUILD_MODE support
Add a Vite plugin (scripts/branding.cjs) that replaces hardcoded "MateClaw" strings at build time, enabling white-label/OEM rebranding without modifying any source code. Configuration: - Edit branding.config.json (name, tagline, team, copyright, appId, githubUrl) - Or set BRAND_* env vars (BRAND_NAME, BRAND_TAGLINE, BRAND_TEAM, etc.) Usage: # Default build (MateClaw brand) npm run package:mac # Custom brand via env vars BRAND_NAME=MyAI BRAND_TAGLINE="Smart AI Helper" npm run package:mac:remote # Or edit branding.config.json and build normally npm run package:mac:remote Replacements applied at build time: - Brand name (window title, About dialog, error messages, console logs) - Tagline, team name, copyright line - GitHub repo/issues URLs - Logo file path - electron-builder config (productName, appId, artifactName, dmg title, publish repo) The branding plugin runs in Vite's transform hook, covering the renderer (App.vue, index.html), electron main process, and preload script. Server-coupled strings (H2 database name, Spring Boot property names) are intentionally NOT replaced to avoid breaking backend compatibility.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
背景
当前桌面端打包会内置完整 JVM 运行时(JRE + Spring Boot JAR ~530MB),安装包体积大。企业用户大量使用 remote 远程连接模式,仅少数场景需要 local 本地内置服务,存在冗余打包开销与分发成本。
优化方案
构建脚本区分打包模式,新增
BUILD_MODE环境变量,支持两种产出包:使用方式
```bash
Local 完整版(默认,内置 JRE+JAR)
npm run package:mac:local
Remote 轻量版(仅客户端,连接远程服务器)
npm run package:mac:remote
Windows
npm run package:win:remote
全平台
npm run package:all:remote
```
electron-builder.json→electron-builder.cjs:动态配置,根据BUILD_MODE条件包含extraResources(JRE/JAR)electron/main/index.ts:运行时检测构建模式(JAR 是否存在),remote 模式下跳过本地后端启动,忽略已保存的 local 配置,新增app:get-build-modeIPC handlerelectron/preload/index.ts:暴露getBuildMode()APIsrc/App.vue:remote 构建隐藏"本地运行"选项,直接显示远程连接表单,展示轻量版提示src/env.d.ts:补充buildMode类型声明package.json:新增package:mac:local/package:mac:remote等脚本,添加cross-env依赖scripts/build.sh:构建 server JAR 并复制到 resources/scripts/download-jre.sh:下载 Eclipse Temurin 21 JRE(支持 mac-arm64/mac-x64)scripts/build-all-platforms.sh:全平台构建脚本,支持--local/--remote参数scripts/trim-playwright-driver.cjs:afterPack hook 占位脚本兼容性
BUILD_MODE默认为local,原有行为不变