-
-
Notifications
You must be signed in to change notification settings - Fork 2k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
inlineStyleThreshold causes relative link to fonts/resources to be broken #6720
Comments
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 this is not exclusive to fontsource packages. i'm using a private font package, and the a copy paste of the thread i opened in the discord, if you want additional context or another example(from https://discord.com/channels/457912077277855764/1208579327575457802/1208579327575457802) hi, i'm trying to inline some styles, and i'm wondering if i'm making a mistake, or i should open a bug on github i've set inlineStyleThreshold here: i'm importing the font + stylesheet from an external package by doing this: the font gets loaded correctly when inlining is not done. however, when sveltekit tries to inline styles, it looks like the build output does not properly transform the paths for the inlined this is output in @font-face{font-family:Editorial New;src:url(/_app/immutable/assets/PPEditorialNew-Italic.Cp3W8-2Y.woff2) format("woff2"); /*snip...*/ this gets output in @font-face{font-family:Editorial New;src:url(./PPEditorialNew-Regular.Dr0yIrkc.woff2) format(\"woff2\"); disabling inlining once again allows the browser to correctly request the font, but there's a noticeable fcp hit |
Another workaround is to set 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?). kit/packages/kit/src/exports/vite/index.js Line 854 in 4ae1cd1
|
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
The text was updated successfully, but these errors were encountered: