From 1b755cb83e8efb01cc507ee3c751a00e0cbd8a22 Mon Sep 17 00:00:00 2001 From: Kent Wang Date: Tue, 2 Jun 2026 16:21:03 +0800 Subject: [PATCH] Fix: dev build environment not inject (#10008) * fix build issue * fix esbuild inject issue --- packages/insomnia/src/common/constants.ts | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/packages/insomnia/src/common/constants.ts b/packages/insomnia/src/common/constants.ts index be55688f7c..bac9257333 100644 --- a/packages/insomnia/src/common/constants.ts +++ b/packages/insomnia/src/common/constants.ts @@ -38,7 +38,8 @@ export const getProductName = () => appConfig.productName; export const getAppSynopsis = () => appConfig.synopsis; export const getAppId = () => appConfig.appId; export const getAppBundlePlugins = () => appConfig.bundlePlugins; -export const getAppEnvironment = () => env.INSOMNIA_ENV || 'production'; +// Must specify full `process.env.INSOMNIA_ENV` here because esbuild define is a build-time replacement and won't inject to runtime +export const getAppEnvironment = () => env.INSOMNIA_ENV || process.env.INSOMNIA_ENV || 'production'; export const isDevelopment = () => getAppEnvironment() === 'development'; export const getSegmentWriteKey = () => appConfig.segmentWriteKeys[isDevelopment() || env.PLAYWRIGHT_TEST ? 'development' : 'production']; @@ -47,7 +48,8 @@ export const getCioWriteKey = () => appConfig.cio[isDevelopment() || env.PLAYWRIGHT_TEST ? 'development' : 'production'].writeKey; export const getCioSiteId = () => appConfig.cio[isDevelopment() || env.PLAYWRIGHT_TEST ? 'development' : 'production'].siteId; -export const getAppBuildDate = () => new Date(env.BUILD_DATE ?? '').toLocaleDateString(); +// Must specify full `process.env.BUILD_DATE` here because esbuild define is a build-time replacement and won't inject to runtime +export const getAppBuildDate = () => new Date((env.BUILD_DATE || process.env.BUILD_DATE) ?? '').toLocaleDateString(); export const getBrowserUserAgent = () => encodeURIComponent(