I am making a web component in Vanilla JS that use a hidden select
in the background and a div
and ul>li
in front. It became a bit complex with fetching data from an api, ect, so I transitioned to Svelte to simplify it and make it more readable.
Now I've tried for 2 days to export the component as an IIFE. I just can't seem to figure out how. I might be mistaken, but I thought that was one of the main features of Svelte - to make reusable components that can be used anywhere. Making it was the easy part, but now I want to load it and use it directly in the browser (with <script src=""></script>
). I thought that should be easy?
I use Svelte 3 (3.57.0) with Vite 4 (4.2.1), and I have tried both npm create svelte
to create a library project with SvelteKit and npm init vite
with svelte
as framework.
I've read quite a lot of the documentation for Vite and Svelte, but it feels overwhelming and I can't seem to find a configuration that works.
Does anyone know how to compile components to IIFEs in Svelte?