You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Furthermore, maybe not the topic of this issue but somewhat related, I'm wondering what should be the behavior of the CSS inlining during dev in regard to dynamic imports in user's code.
Currently Kit makes the assumption that such code will be used on the page and inlines it during dev, as it does (incorrectly) with all the aforementioned cases.
However, this is nor automatically the user's intention, and neither identical to what they will get in the production build. In effect, in Vite those dynamic imports of .css only return the content of the file to the user (similar to ?raw imports actually), it doesn't inject the CSS in the page by itself (like it does with static imports).
Currently, in dev, Kit inlines .css imported like that, but should it? With only that, the style won't appear in the prod build.
import('./example-dynamic.css').then((m)=>{// it gets the raw file contentsconsole.log(m.default);// /* example-dynamic.css */// body {// font-size: 3rem;// }});
Describe the bug
Kit inlines style during dev to reduce FOUC.
However, this inlining is a bit to gready, because it will also include the content of files imported with Vite's special URLs such as:
import raw from 'some.css?raw'
import url from 'some.css?url'
It also inlines glob imports as raw or URL:
import.meta.glob('./*.css', { as: 'raw' })
import.meta.glob('./*.css', { as: 'url' })
Somewhat related: dynamic imports
Furthermore, maybe not the topic of this issue but somewhat related, I'm wondering what should be the behavior of the CSS inlining during dev in regard to dynamic imports in user's code.
Currently Kit makes the assumption that such code will be used on the page and inlines it during dev, as it does (incorrectly) with all the aforementioned cases.
However, this is nor automatically the user's intention, and neither identical to what they will get in the production build. In effect, in Vite those dynamic imports of
.css
only return the content of the file to the user (similar to?raw
imports actually), it doesn't inject the CSS in the page by itself (like it does with static imports).Currently, in dev, Kit inlines
.css
imported like that, but should it? With only that, the style won't appear in the prod build.Reproduction
https://github.com/rixo/repro-kit-inline-raw-css
Open: http://localhost:5173
Go to "view source" to check what the server has rendered.
Observe that some raw URLs and CSS imported as raw text has been inlined in
<style data-sveltekit>
.Logs
No response
System Info
Severity
blocking an upgrade
Additional Information
No response
The text was updated successfully, but these errors were encountered: