-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: 🐛 fix CEM loading in Storybook (#427)
- Loading branch information
1 parent
316c8ba
commit de7368f
Showing
4 changed files
with
31 additions
and
43 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
import { fetchStyleComponents } from './styles-helper'; | ||
import { setCustomElementsManifest } from '@storybook/web-components'; | ||
|
||
export default async function loadCustomElements() { | ||
await fetch('./custom-elements.json'); | ||
|
||
// Use dynamic manifest generated by Vite on runtime | ||
const response = await fetch('./custom-elements.json'); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment | ||
const customElements = await response.json(); | ||
|
||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access, @typescript-eslint/no-unsafe-call | ||
const stylesAreAlreadyIncluded = customElements.modules.some((module: { styles: boolean }) => module.styles); | ||
if (!stylesAreAlreadyIncluded) { | ||
const styleComponents = await fetchStyleComponents(); | ||
// eslint-disable-next-line @typescript-eslint/no-unsafe-assignment, @typescript-eslint/no-unsafe-member-access | ||
customElements.modules = [...customElements.modules, ...styleComponents]; | ||
} | ||
|
||
setCustomElementsManifest(customElements); | ||
console.log('Custom elements manifest loaded'); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters