0
Fork 0
mirror of https://github.com/logto-io/logto.git synced 2024-12-16 20:26:19 -05:00

fix(experience): update dev features flag env handling (#6467)

This commit is contained in:
Xiao Yijun 2024-08-19 17:46:17 +08:00 committed by GitHub
parent b549a7efd6
commit 54881078f1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 9 additions and 1 deletions

View file

@ -1,4 +1,9 @@
import { yes } from '@silverhand/essentials';
const normalizeEnv = (value: unknown) =>
value === null || value === undefined ? undefined : String(value);
const isProduction = import.meta.env.PROD;
export const isDevFeaturesEnabled =
process.env.NODE_ENV !== 'production' || yes(process.env.DEV_FEATURES_ENABLED);
!isProduction || yes(normalizeEnv(import.meta.env.DEV_FEATURES_ENABLED));

View file

@ -26,6 +26,9 @@ const buildConfig = (mode: string): UserConfig => ({
viteCompression({ disable: mode === 'development' }),
viteCompression({ disable: mode === 'development', algorithm: 'brotliCompress' }),
],
define: {
'import.meta.env.DEV_FEATURES_ENABLED': JSON.stringify(process.env.DEV_FEATURES_ENABLED),
},
build: {
// Use the same browserslist configuration as in README.md.
// Consider using the esbuild target directly in the future.