From 9417142ddc50943fc24b3122d90c7c91d9e6992d Mon Sep 17 00:00:00 2001 From: DJ Mountney Date: Thu, 14 Dec 2023 18:12:37 -0800 Subject: [PATCH] Convert env calls --- .../desktop-client/src/browser-preload.browser.js | 6 +++--- packages/desktop-client/vite.config.mts | 12 ++++++------ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/packages/desktop-client/src/browser-preload.browser.js b/packages/desktop-client/src/browser-preload.browser.js index 803ed2ac5b9..5b86f930f4b 100644 --- a/packages/desktop-client/src/browser-preload.browser.js +++ b/packages/desktop-client/src/browser-preload.browser.js @@ -11,7 +11,7 @@ const backendWorkerUrl = new URL('./browser-server.js', import.meta.url); // browser environment this is where we initialize the backend and // everything else. -const IS_DEV = process.env.NODE_ENV === 'development'; +const IS_DEV = import.meta.env.MODE === 'development'; const ACTUAL_VERSION = Platform.isPlaywright ? '99.9.9' : packageJson.version; // *** Start the backend *** @@ -29,8 +29,8 @@ function createBackendWorker() { type: 'init', version: ACTUAL_VERSION, isDev: IS_DEV, - publicUrl: process.env.PUBLIC_URL, - hash: process.env.REACT_APP_BACKEND_WORKER_HASH, + publicUrl: import.meta.env.BASE_URL.slice(0, -1), + hash: import.meta.env.REACT_APP_BACKEND_WORKER_HASH, isSharedArrayBufferOverrideEnabled: localStorage.getItem( 'SharedArrayBufferOverride', ), diff --git a/packages/desktop-client/vite.config.mts b/packages/desktop-client/vite.config.mts index 9fb45f69cf3..70bbf2f8f54 100644 --- a/packages/desktop-client/vite.config.mts +++ b/packages/desktop-client/vite.config.mts @@ -24,13 +24,15 @@ const addWatchers = (): Plugin => ({ }); // https://vitejs.dev/config/ -export default defineConfig(({ mode }) => { +export default defineConfig(async ({ mode }) => { const env = loadEnv(mode, process.cwd(), ''); const devHeaders = { 'Cross-Origin-Opener-Policy': 'same-origin', 'Cross-Origin-Embedder-Policy': 'require-corp', }; + const buildShims = await path.resolve('./src/build-shims.js'); + // Forward Netlify env variables if (process.env.REVIEW_ID) { process.env.REACT_APP_REVIEW_ID = process.env.REVIEW_ID; @@ -117,17 +119,15 @@ export default defineConfig(({ mode }) => { disableGlobbing: false, }, }, - optimizeDeps: { - include: ['process'], - }, resolve: { extensions: resolveExtensions, }, plugins: [ { ...inject({ - global: [path.resolve('src/build-shims.js'), 'global'], - process: [path.resolve('src/build-shims.js'), 'process'], + exclude: ['src/setupTests.jsx'], + global: [buildShims, 'global'], + process: [buildShims, 'process'], }), enforce: 'post', },