natemoo-re / astro-icon

Inline and sprite-based SVGs in Astro made easy!
https://astroicon.dev
Other
990 stars 57 forks source link

"Unable to locate X icon!" without restarting dev server #207

Open bholmesdev opened 4 months ago

bholmesdev commented 4 months ago

What version of astro-icon are you using?

v1.1.0

Astro Info

Astro                    v3.2.3
Node                     v18.18.0
System                   macOS (arm64)
Package Manager          pnpm
Output                   static
Adapter                  none
Integrations             @astrojs/markdoc
                         @astrojs/tailwind
                         astro-icon

If this issue only occurs in one browser, which browser is a problem?

Chrome

Describe the Bug

When adding a new entry to the icons/ directory, I see an "unable to locate X icon!" error. Restarting the dev server resolves the issue. Strangely, this does not occur on initial installation or for the first icon added to icons/. However, after restarting the dev server once and adding more additions to icons/, the error appears.

See stackblitz example below. Try copying a .svg entry under a new name and update the Icon in pages/index.astro to reference it.

image

What's the expected result?

Updates to icons/ are detected while the dev server is running.

Link to Minimal Reproducible Example

https://stackblitz.com/~/edit/github-ds52xs

felixzrte commented 4 months ago

I can't get it to work even if I restart the dev server

bobhuf commented 4 months ago

Same issue here, unfortunately.

Thiago2104 commented 4 months ago

Same issue here but it don't work even if restarting the dev server. It loads small svgs with restarting the dev server, but big svgs are not recognized.

natemoo-re commented 3 months ago

Hmm, very odd. Thanks for the repro! I'll try to figure out what's going on here. Might need to add an explicit watcher for the icons/ directory in the Vite plugin so we can rebuild the virtual module when that's needed.

hkbertoson commented 3 months ago

Not sure if this is related but seems to be. But if I update my Astro Config to have a new icon. I have to restart the dev server for it to pick up that a new one is there. Otherwise, it says that it does not exist.

Start the page and then in the config. Add a new icon and try to use it.

https://stackblitz.com/edit/withastro-astro-qh7fcg

theysamtheirs commented 3 months ago

also reporting the same issue!

faizananwerali commented 3 months ago

+1

Same thing happend to me, had to restart dev server everytime

anridev24 commented 2 months ago

+1

AhmedHamedd2017 commented 2 months ago

+1

cotton123236 commented 1 day ago

+1

Same problem, v0.8.3 is working fine! But it seems no longer support the latest version of Astro.

cotton123236 commented 1 day ago

It seems to be caused by here. https://github.com/natemoo-re/astro-icon/blob/a4ff8736965214e16ce0b72364f43b3a4973f281/packages/core/src/vite-plugin-astro-icon.ts#L33

The icons only be loaded when vite server start, maybe you can add a fs.watch to watch icons dir or any other smarter way to update collections["local"].

Thanks for this great integration by the way.