-
-
Notifications
You must be signed in to change notification settings - Fork 578
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
Project is loading all icons despite only using two. #823
Comments
Hmm interesting. |
@ericfennis I am using Vite 3 which is the standard build tool with svelte. |
@ericfennis any luck duplicating this? |
@JustBarnt yes I was able to replicate this. Not sure what is happening. Vite is importing everything from the index file. I dont understand how the tree shaking is working. I need to check other frameworks as well in vite. |
@ericfennis I can look into seeing how vite does treeshaking as well, maybe I can find a solution and give you an update. |
I've checked other frameworks, but Svelte is the only one that imports each file separately. Other frameworks also loading all the icons but it imports it in one file. On dev mode in vite it doesn't tree-shake. |
I will do some more research |
@ericfennis Yeah I did some searching to found out that people were using |
@JustBarnt Thanks for opening issue in vite repo. The reply in vitejs/vite#10742 by @sapphi-red is the answer for this issue. I can't affect the way vite is loading the imports in the index file in dev mode. See issue in vitejs/vite#8237. |
Hi @JustBarnt, have yfound a workaround for the issue? |
having same issue, any update on this? |
If anyone's still having issues (I guess you do, because I did), this article helped: https://christopher.engineering/en/blog/lucide-icons-with-vite-dev-server/ So, basically we need to create alias in vite.config.ts (author uses solid, we use svelte):
Then we need d.ts file for TypeScript, again for Svelte:
And then we can import icons like that:
Fixed for me |
@Serpentarius13 Glad I was able to help!!!!!!!!!!! |
Prerequisites
Step to reproduce
Install package. I installed the Svelte version. I imported
ChevronUpDown
in one file andInfo
in another. Upon refreshing the page it takes upwards of 5-8 seconds with HMR. Inside the network tab in my dev tools I can see every icon being retrieved with a 200 success status instead of just the two I am using.Actual behavior
I would expect it to only load the icons I am using.
Any message or error
(Type here)
Resources
The text was updated successfully, but these errors were encountered: