From 778b1e7f28529b104290ab920f35394234bdffc0 Mon Sep 17 00:00:00 2001 From: OA Hsiao Date: Wed, 24 Jun 2026 17:57:29 +0800 Subject: [PATCH] build(win): add ARM64 target alongside x64 Build Windows NSIS installers for both x64 and ARM64. Adds per-arch artifactName so each architecture produces its own installer, plus dist:x64 / dist:arm64 convenience scripts. Updates README (EN + ZH) build sections. --- README.md | 27 ++++++++++++++++++++++----- package.json | 17 ++++++++++++++--- 2 files changed, 36 insertions(+), 8 deletions(-) diff --git a/README.md b/README.md index 543016c..94e81c1 100644 --- a/README.md +++ b/README.md @@ -102,15 +102,25 @@ LOG_OUTPUT/ ## 📦 Build the installer -Uses [electron-builder](https://www.electron.build/) to produce a Windows NSIS installer: +Uses [electron-builder](https://www.electron.build/) to produce Windows NSIS installers for +both **x64** and **ARM64**: ```powershell npm install npm run dist ``` -Produces `dist\M2_LOG Setup .exe`. `npm run pack` builds only the unpacked -`dist\win-unpacked\` (for testing). `npm test` runs the static self-tests. +Produces one installer per architecture: + +- `dist\M2_LOG--x64.exe` +- `dist\M2_LOG--arm64.exe` + +To build a single architecture only, use `npm run dist:x64` or `npm run dist:arm64`. +`npm run pack` builds only the unpacked `dist\win-unpacked\` (for testing). `npm test` runs +the static self-tests. + +> ARM64 builds cross-compile fine from an x64 machine — electron-builder downloads the +> matching ARM64 Electron binaries automatically. --- @@ -239,14 +249,21 @@ LOG_OUTPUT/ ## 📦 打包安裝檔 -使用 [electron-builder](https://www.electron.build/) 產生 Windows NSIS 安裝檔: +使用 [electron-builder](https://www.electron.build/) 同時產生 **x64** 與 **ARM64** 兩種 Windows NSIS 安裝檔: ```powershell npm install npm run dist ``` -產生 `dist\M2_LOG Setup <版本>.exe`。`npm run pack` 則只產生未封裝的 `dist\win-unpacked\`(測試用)。`npm test` 執行靜態自我測試。 +會依架構各產生一個安裝檔: + +- `dist\M2_LOG-<版本>-x64.exe` +- `dist\M2_LOG-<版本>-arm64.exe` + +只想建置單一架構時,使用 `npm run dist:x64` 或 `npm run dist:arm64`。`npm run pack` 則只產生未封裝的 `dist\win-unpacked\`(測試用)。`npm test` 執行靜態自我測試。 + +> 在 x64 機器上也能順利交叉編譯出 ARM64 版本 — electron-builder 會自動下載對應的 ARM64 Electron 二進位檔。 --- diff --git a/package.json b/package.json index 41d034e..faf2b1a 100644 --- a/package.json +++ b/package.json @@ -10,7 +10,9 @@ "icon": "node scripts/make-icon.mjs", "test": "node --test test/selftest.test.js", "pack": "electron-builder --dir", - "dist": "electron-builder" + "dist": "electron-builder --win --x64 --arm64", + "dist:x64": "electron-builder --win --x64", + "dist:arm64": "electron-builder --win --arm64" }, "build": { "appId": "com.m2station.m2log", @@ -30,8 +32,17 @@ } ], "win": { - "target": "nsis", - "icon": "build/icon.ico" + "target": [ + { + "target": "nsis", + "arch": [ + "x64", + "arm64" + ] + } + ], + "icon": "build/icon.ico", + "artifactName": "${productName}-${version}-${arch}.${ext}" }, "nsis": { "oneClick": false,