Skip to content
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

font use absolute path assuming the font file will be hosted on the route. #1477

Closed
wighawag opened this issue May 17, 2021 · 3 comments
Closed

Comments

@wighawag
Copy link
Contributor

Describe the bug
in the create svelte default template the following css :

@import '@fontsource/fira-mono';
get generated into font with url referencing font woff file with absolute path. This assume the website is hosted on the root path

Expected behavior
The css generated for font file should use relative path. This should work nicely has relative path in css are relative to the css file itself

@Rich-Harris
Copy link
Member

This is a Vite issue that will hopefully be fixed by vitejs/vite#7644

@iacore
Copy link

iacore commented Apr 25, 2022

This is a Vite issue that will hopefully be fixed by vitejs/vite#7644

It is not that simple. While this simple site using vite works fine, svelte kit breaks this all.

Let's say I want to import a file with import("./import-me.css").

The website is generated at /build/index.html with adapter-static.

The browser tries to fetch /_app/assets/import-me-2d113d6b.css, which is wrong.

If I use base: "./" as vite config, then the browser fetches ./assets/import-me-2d113d6b.css which is /build/assets/import-me-2d113d6b.css, which is wrong again.

The correct path should be /build/_app/assets/import-me-2d113d6b.css.

@iacore
Copy link

iacore commented Apr 25, 2022

Here's the website I was talking about (with instructions on dependencies):
https://github.com/locriacyber/svelte-relative-assets-challenge

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants