Add frontend debug mode gate
This commit is contained in:
23
src/config/debugMode.ts
Normal file
23
src/config/debugMode.ts
Normal file
@@ -0,0 +1,23 @@
|
||||
const DEBUG_MODE_TRUE_VALUES = new Set(['1', 'true', 'yes', 'on']);
|
||||
const DEBUG_MODE_FALSE_VALUES = new Set(['0', 'false', 'no', 'off']);
|
||||
|
||||
function parseOptionalBoolean(value: string | undefined) {
|
||||
const normalizedValue = value?.trim().toLowerCase();
|
||||
if (!normalizedValue) {
|
||||
return null;
|
||||
}
|
||||
if (DEBUG_MODE_TRUE_VALUES.has(normalizedValue)) {
|
||||
return true;
|
||||
}
|
||||
if (DEBUG_MODE_FALSE_VALUES.has(normalizedValue)) {
|
||||
return false;
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
export const IS_DEBUG_MODE =
|
||||
parseOptionalBoolean(import.meta.env.VITE_DEBUG_MODE) ?? import.meta.env.DEV;
|
||||
|
||||
export function isDebugMode() {
|
||||
return IS_DEBUG_MODE;
|
||||
}
|
||||
Reference in New Issue
Block a user