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

Nested font imports 404ing in Vite 2.7.x when a server.origin is set #6622

Closed
7 tasks done
mitchell-ionata opened this issue Jan 25, 2022 · 2 comments · Fixed by #7865
Closed
7 tasks done

Nested font imports 404ing in Vite 2.7.x when a server.origin is set #6622

mitchell-ionata opened this issue Jan 25, 2022 · 2 comments · Fixed by #7865
Labels
documentation Improvements or additions to documentation

Comments

@mitchell-ionata
Copy link

Describe the bug

I am currently experiencing this with Font Awesome, but I imagine it would be an issue in many other cases as well. I am using Font Awesome as a dependency and if I import their compiled css into my main.js, the styles are imported fine but the references to the font files inside the CSS produce a 404 in Vite v2.7.x but it works fine in v2.6.14.

If I set my server.origin in my vite.config.js to http://localhost:3000/ for example, the generated link to a font file will look something like the following: http://localhost:3000//node_modules/@fortawesome/fontawesome-free/webfonts/fa-regular-400.woff2
In v2.6.14 the link looks the same, but does not produce a 404.

Reproduction

https://stackblitz.com/edit/vitejs-vite-ajzary?file=main.js

System Info

N/A

Used Package Manager

npm

Logs

No response

Validations

@toSayNothing
Copy link
Contributor

: await moduleGraph.ensureEntryFromUrl(
(
await fileToUrl(file, config, this)
).replace((config.server?.origin ?? '') + config.base, '/')
)

in your case, change origin to http://localhost:3000 (without slash) works.

@mitchell-ionata
Copy link
Author

Ah thank you! The docs say to include the trailing slash so it didn't occur to me to remove it. https://vitejs.dev/config/#server-origin

@sapphi-red sapphi-red added the documentation Improvements or additions to documentation label Apr 21, 2022
sapphi-red added a commit to sapphi-red/vite that referenced this issue Apr 22, 2022
sapphi-red added a commit to sapphi-red/vite that referenced this issue Apr 22, 2022
@github-actions github-actions bot locked and limited conversation to collaborators May 12, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
documentation Improvements or additions to documentation
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants