soapbox/src/build-config-compiletime.ts

33 lines
564 B
TypeScript
Raw Normal View History

2023-09-13 17:04:17 +00:00
/**
* Build config: configuration set at build time.
* @module soapbox/build-config
*/
const {
NODE_ENV,
BACKEND_URL,
FE_INSTANCE_SOURCE_DIR,
SENTRY_DSN,
} = process.env;
2024-11-19 04:39:23 +00:00
const sanitizeURL = (url: string = ''): string => {
2023-09-13 17:04:17 +00:00
try {
2024-11-19 04:39:23 +00:00
return new URL(url).href;
2023-09-13 17:04:17 +00:00
} catch {
return '';
}
};
2023-09-20 21:02:36 +00:00
const env = {
NODE_ENV: NODE_ENV || 'development',
BACKEND_URL: sanitizeURL(BACKEND_URL),
FE_INSTANCE_SOURCE_DIR: FE_INSTANCE_SOURCE_DIR || 'instance',
SENTRY_DSN,
};
export type SoapboxEnv = typeof env;
2023-09-13 17:04:17 +00:00
export default () => ({
2023-09-20 21:02:36 +00:00
data: env,
2023-09-13 17:04:17 +00:00
});