From ae01066fe2e3d392c16649f05e00479e675443af Mon Sep 17 00:00:00 2001 From: Michael Clark <5285928+MikesGlitch@users.noreply.github.com> Date: Mon, 16 Sep 2024 19:12:25 +0100 Subject: [PATCH] :electron: Reduce package size (#3443) * reduce package size of all packages * release notes * Update beforePackHook.ts --- packages/desktop-electron/beforePackHook.ts | 11 +++++++++++ packages/desktop-electron/package.json | 10 ++++++---- upcoming-release-notes/3443.md | 6 ++++++ 3 files changed, 23 insertions(+), 4 deletions(-) create mode 100644 upcoming-release-notes/3443.md diff --git a/packages/desktop-electron/beforePackHook.ts b/packages/desktop-electron/beforePackHook.ts index 3446378e7..fec75de36 100644 --- a/packages/desktop-electron/beforePackHook.ts +++ b/packages/desktop-electron/beforePackHook.ts @@ -1,4 +1,5 @@ import { rebuild } from '@electron/rebuild'; +import copyFiles from 'copyfiles'; import { Arch, AfterPackContext } from 'electron-builder'; /* The beforePackHook runs before packing the Electron app for an architecture @@ -26,6 +27,16 @@ const beforePackHook = async (context: AfterPackContext) => { }); console.info(`Rebuilt better-sqlite3 with ${arch}!`); + + if (context.packager.platform.name === 'windows') { + console.info(`Windows build - copying appx files...`); + + await new Promise(resolve => + copyFiles(['./appx/**/*', './build'], { error: true }, resolve), + ); + + console.info(`Copied appx files!`); + } } catch (err) { console.error('beforePackHook:', err); process.exit(); // End the process - unsuccessful build diff --git a/packages/desktop-electron/package.json b/packages/desktop-electron/package.json index c561de772..960b789e9 100644 --- a/packages/desktop-electron/package.json +++ b/packages/desktop-electron/package.json @@ -9,20 +9,22 @@ "update-client": "bin/update-client", "build": "yarn build:dist && electron-builder", "build:dist": "tsc --p tsconfig.dist.json && yarn copy-static-assets", - "copy-static-assets": "copyfiles --exclude 'build/**/*' **/*.html icons/**/* appx/**/* build", + "copy-static-assets": "copyfiles --exclude 'build/**/*' **/*.html icons/**/* build", "watch": "yarn build:dist && cross-env ACTUAL_DOCUMENT_DIR=\"../../data\" ACTUAL_DATA_DIR=\"../../data\" electron ." }, "main": "build/index.js", "build": { "appId": "com.actualbudget.actual", "files": [ + "build", "!node_modules/loot-core/src{,/**/*}", "!node_modules/loot-core/lib-dist/{browser,bundle.mobile*}", - "!**/*.js.map", - "!node_modules/@jlongster/sql.js", "!node_modules/absurd-sql", "!node_modules/better-sqlite3/{benchmark,src,bin,docs,deps,build/Release/obj,build/Release/sqlite3.a,build/Release/test_extension.node}", - "build" + "!**/*.js.map", + "!**/stats.json", + "!node_modules/@jlongster/sql.js/**/*", + "!build/client-build/sql-wasm.wasm" ], "beforePack": "./build/beforePackHook.js", "mac": { diff --git a/upcoming-release-notes/3443.md b/upcoming-release-notes/3443.md new file mode 100644 index 000000000..4c1fbda36 --- /dev/null +++ b/upcoming-release-notes/3443.md @@ -0,0 +1,6 @@ +--- +category: Maintenance +authors: [MikesGlitch] +--- + +Reduce size of desktop packages -- GitLab