feathericons / feather

Simply beautiful open-source icons
https://feathericons.com
MIT License
24.9k stars 1.22k forks source link

What is the way to import only certain icons? #1104

Open dionsnoeijen opened 3 years ago

dionsnoeijen commented 3 years ago

This is all I can find: import feather from "feather-icons";.

It helps me to use feather.replace() in this class. But I don't want to load the whole set of icons in my js file. Can I only have the icons imported that I'm actually using?

Thanks!

pizaranha commented 3 years ago

Hi @dionsnoeijen, there is an approach you could consider to solve your need. If you use Icomoon (https://icomoon.io/app/#/select/library) you will see that Feather icons are included in their icon library. You select it and then Icomoon allows you to select which icons will be included in the final generated webfont.

The way I see it, it's a really good way to keep webfonts light and even to include custom icons. I hope this helps.

Valexr commented 3 years ago

https://github.com/feathericons/feather#feathericonsnametosvgattrs

dionsnoeijen commented 3 years ago

Thanks! I will try!

dionsnoeijen commented 3 years ago

@Valexr As soon as I import feather, all icons are imported into js. Am I missing something obvious here?

Valexr commented 3 years ago

Yep, it's not modularity... & bundled all icons in one Object...🤔

pizaranha commented 3 years ago

@Valexr As soon as I import feather, all icons are imported into js. Am I missing something obvious here?

Well, be sure to select only those you will use. I am talking about Icomoon app. When you touch each icon you can toggle the selection.

Valexr commented 3 years ago

One more alt way:

<img src=https://unpkg.com/feather-icons@4.28.0/dist/icons/activity.svg />

<!- or ->

<img src= https://cdn.jsdelivr.net/npm/feather-icons@4.28.0/dist/icons/activity.svg />
Valexr commented 3 years ago

& I make this file: https://gist.github.com/Valexr/6ed010b646470425d896726981c6fae1 Maybe it will be useful

ajitzero commented 2 years ago

I had opened an issue for this last January: #1028

In short, no, the current implementation does not support adding specific icons only in any way.