Open audacioustux opened 2 years ago
hi, just want to add that i'm still experiencing this in my own website.
if it helps at all, i've created a minimal reproduction here https://github.com/EmeraldSnorlax/inline-style-minimal-reproduction
this is not exclusive to fontsource packages. i'm using a private font package, and the url()
s in css do not get properly transformed if the css is inlined. it otherwise works perfectly in dev mode, or if the @font-face
rule doesn't get inlined in production.
Another workaround is to set kit.config.paths.relative
to false
.
https://kit.svelte.dev/docs/configuration
The issue is that the style inlining process is using the client bundle stylesheets (which have relative paths) instead of the server ones (non-relative paths). We can either use the server bundle stylesheets to inline or try to repair the relative URLs when inlining the client bundle ones (I think the former is safer?). https://github.com/sveltejs/kit/blob/4ae1cd152a60a22044ab3b8aa5572a2b79864583/packages/kit/src/exports/vite/index.js#L854
Describe the bug
it works fine in dev mode, but with inlineStyleThreshold: 32 1024 and vite.build.assetsInlineLimit: 2 1024, the relative links to font files (e.g. .woff2) gets broken, as the css is now resides in html, and the font file in .svelte-kit/output/.. and i can't change the url to absolute url either, as I faced the issue with @fontsource/* fonts.
Reproduction
use any relative url in css, and make sure inlineStyleThreshold causes the css to be inlined
Logs
System Info
Severity
serious, but I can work around it
Additional Information
i had to disable inlineStyleThreshold, and call it a workaround