Open Clindbergh opened 3 years ago
The code gen for this is simple enough, but the main issue with doing this is it breaks simple dead code elimination, as suddenly you hold a reference to every icon.
Maybe that's fine for your use case, but if I was going to implement generation for this I'd probably want to offer some kind of manual subsetting as most people won't want to ship every icon which is a lot of extra data for ones unlikely to actually be used.
What would your use case be, would you want a manual subset or the whole of FA?
Oh, I see. I haven't thought about that.
I am assuming that dead code elimination would still work if the function to convert a string to an icon is not used. The use cases where a subset has to be accessible through a string and where the whole FA can't be loaded are probably limited.
In my case I need the whole FA. But a subset function (which should be easy to implement) would also be nice.
I am interested in this, too. In my use case, I am loading entities from an external service via rest. These entities contain the font-awesome icon name as a string attribute and I want to show respective icon in the web app. All free solid icons would be sufficient for me. How big would the asset be approximately, to contain all these icons svg's if dead code elimination wouldn't work any longer for them?
I am interested in this, too. In my use case, I am loading entities from an external service via rest. These entities contain the font-awesome icon name as a string attribute and I want to show respective icon in the web app. All free solid icons would be sufficient for me. How big would the asset be approximately, to contain all these icons svg's if dead code elimination wouldn't work any longer for them?
Probably about 2MB uncompressed if you take all of the free icons, although there is already support for manual subsetting, so you could choose to have less.
I think the optimal thing would be to add this to the generator as an option, and if you want to do it you generate your own version with it and a subset, to avoid the footgun potential of having it in the library in the Elm package repo. Would that be suitable for your use case? I'd expect most people who want to do this to subset out thinks like brands or other stuff to reduce the overall size.
Been very busy recently and not had a lot of time, so even though this is a small change, probably not something I'll get to soon: PRs welcome.
Ok, thanks for the update! The approach you are suggesting sounds reasonable for me. My context for this is a private side project for me. So time is limited, too. I can't promise anythin, but if I find the time, I will take a look.
I wish there was a function to retrieve an
Icon
(or aMaybe Icon
) using the class name asString
. In my case the class names are stored in the database, so a mapping is needed.