-
-
Notifications
You must be signed in to change notification settings - Fork 9.4k
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
[Bug]: FavIcon doesn't load on localhost with Vite builder #21245
Comments
I can confirm this. I'm using @storybook/vue3-vite and I also don't have a favicon. (on 7.0.0-rc9) There is a favicon declared in the header: <link rel="icon" type="image/svg+xml" href="./favicon.svg"> But when navigating to it, you get a 404. There is a favicon.ico though, but it seems nothing but a 328 bytes blank square. |
Can confirm, still present on 7.5.0-alpha.1. |
@JorisAerts I don't know if it has to do with the fact, that some browsers don't display the icon if they are local (Chrome, Safari). |
Having a similar issue, and I believe it's because when you build for production, Vite hashes all static files to bust the cache and be sure that users get any updates. Most internal views/components are updated on build to reflect this change - but anything in index.html that is "hard coded" does not get this update. So the actual filename for your favicon is being hashed on build. |
@IanVS Does that make sense to you? What would be an appropriate fix/solution? |
@ndelangen, I do not see this behavior. The favicon is working fine in both my app, as well as in a new Storybook. Does someone have a reproduction for us to look at? |
I don't know why but for me the favicon works if there is no "/" right after the href. Just be sure there's no "/" in the beginning of href. Hopefully, it'll work. Donno why though. |
in the index file I added |
I ran into this as well in a different app, and it appears that on localhost the favicon only appears if I prepend the path with public:
|
@ritute I thought I had fixed this, Can you supply a repro with the failure that caused you to add that work-around? |
It's in a different project, not storybook, but just wanted to share what I had to do in my Vite project to fix this similar issue in case somebody here runs into it or comes across this from google searches for it. |
Describe the bug
The favicon is not loading on localhost when Vite builder is being used.
To Reproduce
Create a React project using Vite and TypeScript, and then initialize and start Storybook (next) on it:
This is what I get:
Notice the lack of a favicon on the tab. Inspecting the page, I found that it was trying to use
./favicon.svg
, buthttp://localhost:6006/favicon.svg
does not find anything:After building, it works:
System
Additional context
This was probably introduced by #20130. This PR was released on
7.0.0-alpha.62
, and if I downgrade to7.0.0-alpha.61
, the favicon seems to show up just fine:#20612 might also be related.
The text was updated successfully, but these errors were encountered: