From 8a5ba822be8718aab521c70b9a040b8e780ee843 Mon Sep 17 00:00:00 2001 From: Mike Clark Date: Tue, 4 Mar 2025 22:09:03 +0000 Subject: [PATCH] updating reference to webroot --- packages/desktop-electron/index.ts | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/packages/desktop-electron/index.ts b/packages/desktop-electron/index.ts index 49786d58f9a..65aef5a0d99 100644 --- a/packages/desktop-electron/index.ts +++ b/packages/desktop-electron/index.ts @@ -223,22 +223,27 @@ async function startSyncServer() { 'app.js', ); - const webRoot = path.join( - // require.resolve will recursively search up the workspace for the module - path.dirname(require.resolve('@actual-app/web/package.json')), - 'build', - ); - // Use env variables to configure the server - const envVariables: Env = { + let envVariables: Env = { ...process.env, // required ACTUAL_PORT: `${syncServerConfig.port}`, ACTUAL_SERVER_FILES: `${syncServerConfig.ACTUAL_SERVER_FILES}`, ACTUAL_USER_FILES: `${syncServerConfig.ACTUAL_USER_FILES}`, ACTUAL_DATA_DIR: `${syncServerConfig.ACTUAL_SERVER_DATA_DIR}`, - ACTUAL_WEB_ROOT: webRoot, }; + if (isDev) { + // If we're in dev, use the workspace build of the web app - otherwise use what's in the sync-server (currently an npm package) + // We can remove this isDev condition when sync-server also uses the workspace build + const webRoot = path.join( + // require.resolve will recursively search up the workspace for the module + path.dirname(require.resolve('@actual-app/web/package.json')), + 'build', + ); + + envVariables = { ...envVariables, ACTUAL_WEB_ROOT: webRoot }; + } + // ACTUAL_SERVER_DATA_DIR is the root directory for the sync-server if (!fs.existsSync(syncServerConfig.ACTUAL_SERVER_DATA_DIR)) { mkdir(syncServerConfig.ACTUAL_SERVER_DATA_DIR, { recursive: true });