From 305c13d3f586afca01daf7bc607d2623ccb65a33 Mon Sep 17 00:00:00 2001 From: btc69m979y-dotcom Date: Mon, 2 Mar 2026 15:19:55 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20Windows=20=E5=B9=B3=E5=8F=B0=20electron-?= =?UTF-8?q?builder=20=E6=89=93=E5=8C=85=20asar=20=E7=BC=BA=E5=A4=B1=20dist?= =?UTF-8?q?=20=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 将 electron-builder.json 中 files 配置从 glob 字符串改为对象格式, 使用 from/to/filter 明确指定 dist 和 dist-electron 目录。 glob 字符串格式 ("dist/**/*") 在 Windows 上由于路径分隔符差异, minimatch partial matching 无法正确识别目录,导致 dist/ 和 dist-electron/ 未被打包进 asar,构建失败。 同时添加 .npmignore 确保 electron-builder 不会因 .gitignore 排除 构建产物目录。 --- .npmignore | 44 +++++++++++++++++++++++++++++++++++++++++++ electron-builder.json | 14 +++++++++++--- 2 files changed, 55 insertions(+), 3 deletions(-) create mode 100644 .npmignore diff --git a/.npmignore b/.npmignore new file mode 100644 index 0000000..cf5f24c --- /dev/null +++ b/.npmignore @@ -0,0 +1,44 @@ +# .npmignore - Used by electron-builder instead of .gitignore +# This file intentionally does NOT exclude dist/ and dist-electron/ +# so that build outputs are included in the asar archive. + +src/ +tests/ +scripts/ +build/* +!build/entitlements.mac.plist +!build/icons/ +!build/icons/** +release/ +.DS_Store +.env +.claude/ +__pycache__/ +.codebuddy/ +sandbox/image/out/ +sandbox/image/publish/ +sandbox/image/.work/ +sandbox/runtime/out/ +sandbox/runtime-darwin-*/ +resources/mingit/ +resources/MinGit-*.zip +resources/PortableGit-*.7z.exe +resources/python-win/ +resources/python-*.zip +SKILLs/**/.connection +SKILLs/**/.server.log +SKILLs/**/.server.pid +SKILLs/**/.venv/ +nul +.work.env +.playwright-mcp/ +.cowork-temp/ +*.ts +!*.d.ts +tsconfig.json +electron-tsconfig.json +vite.config.ts +tailwind.config.js +postcss.config.js +.eslintrc.cjs +CLAUDE.md diff --git a/electron-builder.json b/electron-builder.json index f67e6e7..a9c84ba 100644 --- a/electron-builder.json +++ b/electron-builder.json @@ -8,9 +8,17 @@ "beforePack": "./scripts/electron-builder-hooks.cjs", "afterPack": "./scripts/electron-builder-hooks.cjs", "files": [ - "dist/**/*", - "dist-electron/**/*", - "sandbox/agent-runner/AGENT_SYSTEM_PROMPT.md" + "sandbox/agent-runner/AGENT_SYSTEM_PROMPT.md", + { + "from": "dist", + "to": "dist", + "filter": ["**/*"] + }, + { + "from": "dist-electron", + "to": "dist-electron", + "filter": ["**/*"] + } ], "extraResources": [ {