Open romanr opened 6 years ago
Usually all icons are stored in same folder. And it's a lot of code to specify each icon separately.
Rather than having tens of these lines:
import Icon1 from '/icons/Icon1.svg'; import Icon2 from '/icons/Icon2.svg'; import Icon3 from '/icons/Icon3.svg';
Is it possible to do something like this?
import icon* from '/icons/';
So you just drop images in that folder and they are ready to use.
If that's not possible, maybe have array of image names and import them?
like:
icons['Icon1.svg','icon2.svg','icon3.svg']; import icons;
If not, is there any way to simplify an avoid having all that import code for each image?
A suggestion would be maybe create a new file that you import all your SVGs and then export them all, so then in your component you just import the icons like so
{ myIcon1, myIcon2, myIcon3 } from "./icons"
Usually all icons are stored in same folder. And it's a lot of code to specify each icon separately.
Rather than having tens of these lines:
Is it possible to do something like this?
So you just drop images in that folder and they are ready to use.
If that's not possible, maybe have array of image names and import them?
like:
If not, is there any way to simplify an avoid having all that import code for each image?