fix: Windows 平台 electron-builder 打包 asar 缺失 dist 目录

将 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 排除
构建产物目录。
This commit is contained in:
btc69m979y-dotcom
2026-03-02 15:19:55 +08:00
parent 65a131f780
commit 305c13d3f5
2 changed files with 55 additions and 3 deletions
+44
View File
@@ -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
+11 -3
View File
@@ -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": [
{