bigbuffet-rw/packages/pl-fe/src/custom.ts
marcin mikołajczak 966b04fdf0 Call it pl-fe internally
Signed-off-by: marcin mikołajczak <git@mkljczk.pl>
2024-08-28 13:41:08 +02:00

16 lines
479 B
TypeScript

/**
* Functions for dealing with custom build configuration.
*/
import * as BuildConfig from 'pl-fe/build-config';
/** Require a custom JSON file if it exists */
const custom = (filename: string, fallback: any = {}): any => {
if (BuildConfig.NODE_ENV === 'test') return fallback;
const modules = import.meta.glob('../custom/*.json', { eager: true });
const key = `../../custom/${filename}.json`;
return modules[key] ? modules[key] : fallback;
};
export { custom };