@itwin/itwinui-react
Version:
A react component library for iTwinUI
24 lines (23 loc) • 569 B
JavaScript
export const importCss = async (url) => {
try {
return await new Function(
`return import("${url}", { with: { type: "css" } })`,
)();
} catch {
try {
return await new Function(
`return import("${url}", { assert: { type: "css" } })`,
)();
} catch {
return await fetch(url)
.then((res) => res.text())
.then((cssText) => {
let stylesheet = new CSSStyleSheet();
stylesheet.replaceSync(cssText);
return {
default: stylesheet,
};
});
}
}
};