From 58cce1758888100d122b24e6be4d5133fd4b97a3 Mon Sep 17 00:00:00 2001 From: Johannes Klein Agents Date: Wed, 25 Nov 2026 15:41:03 +0100 Subject: [PATCH] Resolve the static folder from the app's Resources when packaged (#369) electron.vite.config.js baked the build machine's absolute static/ path into out/main/index.js as __static, so a packaged app looked for RAxML, readal and ASTRAL in the CI runner's checkout. getStaticDir() now uses process.resourcesPath/static when packaged, where extraResources copies the binaries, and the repo's static/ otherwise. The __static define and its declaration are gone. Co-Authored-By: Claude Opus 5.5 --- README.md | 2 +- electron.vite.config.js | 4 ---- src/__static.d.ts | 1 - src/main/processHelpers.ts | 8 ++++---- 4 files changed, 5 insertions(+), 10 deletions(-) delete mode 100644 src/__static.d.ts diff --git a/README.md b/README.md index c6d4bc10..3c844d1b 100644 --- a/README.md +++ b/README.md @@ -23,7 +23,7 @@ yarn download-binaries yarn test:e2e ``` -The launch sets `RAXMLGUI_E2E=1`. That skips auto-update checks and points the main process at the repo `static/` directory (example files, binaries, and test output). The built page loads that example alignment from the same flag. +The launch sets `RAXMLGUI_E2E=1`. That skips auto-update checks. The unpacked main process reads example files and binaries from the repo `static/` directory and writes test output there. The built page loads that example alignment from the same flag. ## Input formats diff --git a/electron.vite.config.js b/electron.vite.config.js index ef6879eb..54bbf348 100644 --- a/electron.vite.config.js +++ b/electron.vite.config.js @@ -18,10 +18,6 @@ function sourceMapUpload( command ) { export default defineConfig( ( { command } ) => ( { main: { - // electron-webpack injected this path. The main process still reads the repo's static files through it. - define: { - __static: JSON.stringify( resolve( __dirname, 'static' ) ), - }, plugins: sourceMapUpload( command ), }, preload: { diff --git a/src/__static.d.ts b/src/__static.d.ts deleted file mode 100644 index 7b81469e..00000000 --- a/src/__static.d.ts +++ /dev/null @@ -1 +0,0 @@ -declare const __static: string; diff --git a/src/main/processHelpers.ts b/src/main/processHelpers.ts index 78c947c8..2079a632 100644 --- a/src/main/processHelpers.ts +++ b/src/main/processHelpers.ts @@ -34,11 +34,11 @@ interface RunProcessHooks { onStdErr?: ( content: string ) => void; } +// Packaged: electron-builder's extraResources copies static/ beside the asar. Unpacked: out/main/ sits two levels below the repo root. export function getStaticDir(): string { - if ( process.env.RAXMLGUI_E2E === '1' ) { - return path.join( __dirname, '..', '..', 'static' ); - } - return __static; + return app.isPackaged + ? path.join( process.resourcesPath, 'static' ) + : path.join( __dirname, '..', '..', 'static' ); } export const get_space_safe_binary_path = ( bin_path: string ): string => {