This commit is contained in:
darenhsu
2022-07-17 13:16:16 +08:00
parent 84759556ff
commit befd344ab0
28070 changed files with 4008428 additions and 1 deletions
+21
View File
@@ -0,0 +1,21 @@
import {StyleResources, StyleResourcesLoaderNormalizedOptions} from '..';
import {isPromise, errorMessage} from '.';
export const injectResources = async (
options: StyleResourcesLoaderNormalizedOptions,
source: string,
resources: StyleResources,
) => {
const {injector} = options;
const dist: any = injector(source, resources);
const content = isPromise(dist) ? await dist : dist;
if (typeof content !== 'string') {
throw new Error(errorMessage.invalidInjectorReturn);
}
return content;
};