halfmoonui / halfmoon

Halfmoon is a highly customizable, drop-in Bootstrap replacement. It comes with three built-in core themes, with dark mode support for all themes and components.
https://www.gethalfmoon.com
MIT License
3.01k stars 118 forks source link

require problem while using with sveltekit. #127

Open xeroticikot opened 2 years ago

xeroticikot commented 2 years ago

How can npm installation can be used in sveltekit? Tried different ways, but nothing's working for me. Any reference would've been helpful & much appreciated.

EPD24 commented 1 year ago

Svelte doesn't support require so you have to use import instead, and since import creates a promise you need to use await on the import before initialising inside the DOM.

    import { onMount } from "svelte";
    import("halfmoon/css/halfmoon-variables.min.css");

    onMount(async () => {
    const halfmoon = await import("halfmoon");
    halfmoon.default.onDOMContentLoaded();
    });