-
Notifications
You must be signed in to change notification settings - Fork 84
Not working with Svelte Kit (Vite) #171
Comments
This is probably the Vite-Version of #132. I think I saw the same error on svelte discord, might be a problem with external components right now in general. |
Updating to the given vite config makes that error go away but this new error pops up.
and this is the output in the terminal
|
Can you try something? Slider is calling the nouislider stuff, so you can basically either wrap the call to nouislider in process.browser (or whatever it is in sveltekit) OR inside the nouislider code. If you don't know how/that doesn't work, you can try importing as specific as possible, so from 'svelte-materialify/src/components/Button/Button.svelte' (hope I got that right). |
Yes. Importing in that very specific way works! However I was planning to eventually use the Slider component (very few component libraries provide it!). Let's see. Hoping to see everything stabilize soon. |
Unfortunately I cannot see any styling at all. The button is just plain HTML button now. :( |
The problem is that we are using nouislider underneath, which calls window and Vite doesn't like calling window, I guess, because SSR? Maybe you can specify to not SSR for Slider? In sapper you could do Styling: huh, but maybe something like our Advanced Install is just not working in Vite right now. |
Steps to reproduce the error
<script>
import Button from "svelte-materialify/src/components/Button/Button.svelte";
import MaterialApp from "svelte-materialify/src/components/MaterialApp/MaterialApp.svelte";
</script>
<MaterialApp theme="light">
<Button class="red-text">Hello</Button>
</MaterialApp>
|
You need to setup https://svelte-materialify.vercel.app/getting-started/installation/#advanced-install somehow, right? If there're no styles, preprocessing is missing probably |
Can you please write a guide because the project structure is quite different in SvelteKit? |
I had the same issue and I was able to fix it following suggesting from here: By editing replacing: However, this solution is not tested for SSR mode. Still, I hope you find it useful. |
Based on these two resources : - TheComputerM#171 (comment) - https://kit.svelte.dev/docs#troubleshooting-server-side-rendering
@V-ed What's your config? Seems vite does it differently from rollup |
Is the problem still happening? Vite uses rollup internally, and SvelteKit uses vite internally - I thought this would therefore fix both at the same time (it does for my project). I just pushed a commit with a basic setup of Materialify on my repo, you can see my setup here : https://github.com/V-ed/svelte-typescript-routing-template/tree/f0735c60191efe4fb5b443b3eac21a0266780ecf |
I am not sure if there is some special configuration to do with https://github.com/sveltejs/kit but this is the error I am getting when trying to use a simple Button component.
The text was updated successfully, but these errors were encountered: