保誠-保戶業務員媒合平台
HelenHuang
2022-06-09 9bdb95c9e34cef640534e5e5a1e2225a80442000
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
import type {LoaderContext, LoaderCallback} from '../types';
 
import {getResources} from './get-resources';
import {injectResources} from './inject-resources';
import {normalizeOptions} from './normalize-options';
 
export const loadResources = async (ctx: LoaderContext, source: string, callback: LoaderCallback) => {
    try {
        const options = normalizeOptions(ctx);
 
        const resources = await getResources(ctx, options);
 
        const content = await injectResources(ctx, options, source, resources);
 
        callback(null, content);
    } catch (err: unknown) {
        callback(err as Error);
    }
};