Skip to content

Voice-to-text dictation app with local (Nvidia Parakeet/Whisper) and cloud models (BYOK). Privacy-first and available cross-platform.

chore: optimize build size by excluding dev dependencies and platform-specific binaries

Gabriel Stein9ef17a9ac4e5
diff --git a/.github/workflows/build-and-notarize.yml b/.github/workflows/build-and-notarize.yml
index 31aa8874f..f874e11d2 100644
--- a/.github/workflows/build-and-notarize.yml
+++ b/.github/workflows/build-and-notarize.yml
@@ -23,7 +23,7 @@ jobs:
run: npm ci
- name: Download whisper.cpp binaries
- run: node scripts/download-whisper-cpp.js
+ run: node scripts/download-whisper-cpp.js --current
- name: Cache Electron
uses: actions/cache@v4
@@ -62,7 +62,7 @@ jobs:
run: npm ci
- name: Download whisper.cpp binaries
- run: node scripts/download-whisper-cpp.js
+ run: node scripts/download-whisper-cpp.js --current
- name: Download nircmd.exe
run: node scripts/download-nircmd.js
@@ -105,7 +105,7 @@ jobs:
run: npm ci
- name: Download whisper.cpp binaries
- run: node scripts/download-whisper-cpp.js
+ run: node scripts/download-whisper-cpp.js --current --platform darwin --arch ${{ matrix.arch }}
- name: Cache Electron
uses: actions/cache@v4
diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml
index 3b53e9364..5ddb3ebed 100644
--- a/.github/workflows/release.yml
+++ b/.github/workflows/release.yml
@@ -30,7 +30,7 @@ jobs:
run: npm ci
- name: Download whisper.cpp binaries
- run: node scripts/download-whisper-cpp.js
+ run: node scripts/download-whisper-cpp.js --current
- name: Cache Electron
uses: actions/cache@v4
@@ -64,7 +64,7 @@ jobs:
run: npm ci
- name: Download whisper.cpp binaries
- run: node scripts/download-whisper-cpp.js
+ run: node scripts/download-whisper-cpp.js --current
- name: Download nircmd.exe
run: node scripts/download-nircmd.js
@@ -100,7 +100,7 @@ jobs:
run: npm ci
- name: Download whisper.cpp binaries
- run: node scripts/download-whisper-cpp.js
+ run: node scripts/download-whisper-cpp.js --current --platform darwin --arch ${{ matrix.arch }}
- name: Cache Electron
uses: actions/cache@v4
diff --git a/electron-builder.json b/electron-builder.json
index 86929cca3..41941bc0c 100644
--- a/electron-builder.json
+++ b/electron-builder.json
@@ -22,7 +22,59 @@
"src/updater.js",
"src/components.json",
"!node_modules/.cache/**/*",
- "!src/node_modules/**/*"
+ "!src/node_modules/**/*",
+
+ "!**/node_modules/electron/**",
+ "!**/node_modules/electron-builder/**",
+ "!**/node_modules/app-builder-bin/**",
+ "!**/node_modules/app-builder-lib/**",
+ "!**/node_modules/builder-util/**",
+ "!**/node_modules/dmg-builder/**",
+ "!**/node_modules/7zip-bin/**",
+
+ "!**/node_modules/typescript/**",
+ "!**/node_modules/prettier/**",
+ "!**/node_modules/eslint/**",
+ "!**/node_modules/eslint-*/**",
+ "!**/node_modules/@eslint/**",
+ "!**/node_modules/@typescript-eslint/**",
+ "!**/node_modules/globals/**",
+
+ "!**/node_modules/vite/**",
+ "!**/node_modules/@vitejs/**",
+ "!**/node_modules/esbuild/**",
+ "!**/node_modules/@esbuild/**",
+ "!**/node_modules/rollup/**",
+ "!**/node_modules/@rollup/**",
+
+ "!**/node_modules/postcss/**",
+ "!**/node_modules/autoprefixer/**",
+ "!**/node_modules/tailwindcss/**",
+ "!**/node_modules/@tailwindcss/**",
+ "!**/node_modules/lightningcss*/**",
+
+ "!**/node_modules/react/**",
+ "!**/node_modules/react-dom/**",
+ "!**/node_modules/lucide-react/**",
+ "!**/node_modules/@radix-ui/**",
+ "!**/node_modules/class-variance-authority/**",
+ "!**/node_modules/clsx/**",
+ "!**/node_modules/tailwind-merge/**",
+ "!**/node_modules/tw-animate-css/**",
+ "!**/node_modules/react-markdown/**",
+ "!**/node_modules/shadcn-ui/**",
+
+ "!**/node_modules/@types/**",
+ "!**/node_modules/concurrently/**",
+ "!**/node_modules/cross-env/**",
+ "!**/node_modules/@electron/notarize/**",
+
+ "!**/node_modules/**/test/**",
+ "!**/node_modules/**/tests/**",
+ "!**/node_modules/**/*.ts",
+ "!**/node_modules/**/*.map",
+ "!**/node_modules/**/CHANGELOG*",
+ "!**/node_modules/**/.github/**"
],
"asarUnpack": [
"**/node_modules/ffmpeg-static/**/*",
diff --git a/scripts/download-whisper-cpp.js b/scripts/download-whisper-cpp.js
index ad9030950..68aa51e4c 100644
--- a/scripts/download-whisper-cpp.js
+++ b/scripts/download-whisper-cpp.js
@@ -235,8 +235,9 @@ async function downloadBinary(platformArch, config, label) {
async function downloadForPlatform(platformArch) {
// Download both CLI and server binaries for the platform
- await downloadBinary(platformArch, CLI_BINARIES[platformArch], "[cli]");
- await downloadBinary(platformArch, SERVER_BINARIES[platformArch], "[server]");
+ const cliOk = await downloadBinary(platformArch, CLI_BINARIES[platformArch], "[cli]");
+ const serverOk = await downloadBinary(platformArch, SERVER_BINARIES[platformArch], "[server]");
+ return cliOk && serverOk;
}
async function main() {
@@ -247,12 +248,55 @@ async function main() {
const currentPlatform = process.platform;
const currentArch = process.arch;
- const currentPlatformArch = `${currentPlatform}-${currentArch}`;
+
+ // Parse command-line arguments for explicit platform/arch
+ let targetPlatform = currentPlatform;
+ let targetArch = currentArch;
+
+ const platformIndex = process.argv.indexOf('--platform');
+ if (platformIndex !== -1 && process.argv[platformIndex + 1]) {
+ targetPlatform = process.argv[platformIndex + 1];
+ }
+
+ const archIndex = process.argv.indexOf('--arch');
+ if (archIndex !== -1 && process.argv[archIndex + 1]) {
+ targetArch = process.argv[archIndex + 1];
+ }
+
+ const targetPlatformArch = `${targetPlatform}-${targetArch}`;
+ const isCI = process.env.CI === "true" || process.env.GITHUB_ACTIONS === "true";
+ const shouldCleanup = process.argv.includes("--clean") || isCI;
if (process.argv.includes("--current")) {
- // Only download for current platform
- console.log(`Downloading for current platform (${currentPlatformArch}):`);
- await downloadForPlatform(currentPlatformArch);
+ if (!CLI_BINARIES[targetPlatformArch] || !SERVER_BINARIES[targetPlatformArch]) {
+ console.error(`Unsupported platform/arch: ${targetPlatformArch}`);
+ process.exitCode = 1;
+ return;
+ }
+
+ // Only download for specified platform/arch
+ console.log(`Downloading for target platform (${targetPlatformArch}):`);
+ const downloadOk = await downloadForPlatform(targetPlatformArch);
+ if (!downloadOk) {
+ console.error(`Failed to download binaries for ${targetPlatformArch}`);
+ process.exitCode = 1;
+ return;
+ }
+
+ if (shouldCleanup) {
+ // Clean old binaries that don't match target platform/arch
+ const existingFiles = fs.readdirSync(BIN_DIR).filter(f => f.startsWith("whisper-"));
+ const targetPrefix = `whisper-cpp-${targetPlatformArch}`;
+ const targetServerPrefix = `whisper-server-${targetPlatformArch}`;
+
+ existingFiles.forEach(file => {
+ if (!file.startsWith(targetPrefix) && !file.startsWith(targetServerPrefix)) {
+ const filePath = path.join(BIN_DIR, file);
+ console.log(`Removing old binary: ${file}`);
+ fs.unlinkSync(filePath);
+ }
+ });
+ }
} else if (process.argv.includes("--cli-only")) {
// Only download CLI binaries (no server)
console.log("Downloading CLI binaries only:");
diff --git a/src/models/modelRegistryData.json b/src/models/modelRegistryData.json
index 71d9e6399..c92a01401 100644
--- a/src/models/modelRegistryData.json
+++ b/src/models/modelRegistryData.json
@@ -416,4 +416,4 @@
]
}
]
-}
\ No newline at end of file
+}