Description
Describe the problem
Currently in Svelte Kit the recommended way to import global styles or scripts is in your root layout, this is a problem for the following reasons:
- Slower connects will receive a FOUC (Flash Of Unstyled Content)
- Resets will remove these applied style sheets
- Styles won't be applied if js isn't functioning correctly (in some contexts)
- (opinion) it's weird
Describe the proposed solution
I was reading up in the discord and issues here and I believe one of the following is the best solution:
-
A global js/ts file and global css/scss file
this would be my initial guess at a solution and it was even shown here Allow inclusion of global styles #1948 but the downsides are that users might want more than provided options such as less or another javascript superset that isn't provided and adding a option might add extra complexity
-
A global js/ts file
Vite already allows for this easily and can just be treated as a secondary entry point I guess. This is already what you do in vanilla vite, for example on my personal site which is currently in routify
-
A global svelte file
This might be familiar for those using vanilla svelte, having a App.svelte (this case would probably be better for a global.svelte file). This can be where you import your global styles but also global scripts and logic. Again this is how things are done on sites in Routify, for example global keybinds
-
Processing app.html
It might be also possible to process the scripts and links inside of app.html and have this the place your global files are placed (processing is necessary since the script or style might be in a superset such as typescript or sass)
Alternatives considered
Writing a script or vite plugin to do this for me but this is just bad for the community
Importance
i cannot use SvelteKit without it
Additional Information
No response