2021-04-30 16:58:40 +02:00
|
|
|
export const env = {
|
|
|
|
|
NODE_ENV: process.env.NODE_ENV,
|
2021-12-29 23:51:30 +01:00
|
|
|
DEBUG: resolveDebug(process.env.DEBUG),
|
2022-11-30 00:10:15 +01:00
|
|
|
OXIDE: process.env.OXIDE,
|
2021-04-30 16:58:40 +02:00
|
|
|
}
|
|
|
|
|
export const contextMap = new Map()
|
|
|
|
|
export const configContextMap = new Map()
|
|
|
|
|
export const contextSourcesMap = new Map()
|
2022-02-25 13:12:45 -05:00
|
|
|
export const sourceHashMap = new Map()
|
2022-02-15 13:44:19 -05:00
|
|
|
export const NOT_ON_DEMAND = new String('*')
|
2021-12-29 23:51:30 +01:00
|
|
|
|
2022-10-18 21:42:17 +02:00
|
|
|
export const NONE = Symbol('__NONE__')
|
|
|
|
|
|
2021-12-29 23:51:30 +01:00
|
|
|
export function resolveDebug(debug) {
|
|
|
|
|
if (debug === undefined) {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Environment variables are strings, so convert to boolean
|
|
|
|
|
if (debug === 'true' || debug === '1') {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (debug === 'false' || debug === '0') {
|
|
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// Keep the debug convention into account:
|
|
|
|
|
// DEBUG=* -> This enables all debug modes
|
|
|
|
|
// DEBUG=projectA,projectB,projectC -> This enables debug for projectA, projectB and projectC
|
|
|
|
|
// DEBUG=projectA:* -> This enables all debug modes for projectA (if you have sub-types)
|
|
|
|
|
// DEBUG=projectA,-projectB -> This enables debug for projectA and explicitly disables it for projectB
|
|
|
|
|
|
|
|
|
|
if (debug === '*') {
|
|
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
let debuggers = debug.split(',').map((d) => d.split(':')[0])
|
|
|
|
|
|
2021-12-30 16:41:23 +01:00
|
|
|
// Ignoring tailwindcss
|
|
|
|
|
if (debuggers.includes('-tailwindcss')) {
|
2021-12-29 23:51:30 +01:00
|
|
|
return false
|
|
|
|
|
}
|
|
|
|
|
|
2021-12-30 16:41:23 +01:00
|
|
|
// Including tailwindcss
|
|
|
|
|
if (debuggers.includes('tailwindcss')) {
|
2021-12-29 23:51:30 +01:00
|
|
|
return true
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return false
|
|
|
|
|
}
|