Skip to content
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

Is "import all in path" possible? #97

Open
romanr opened this issue Mar 31, 2018 · 1 comment
Open

Is "import all in path" possible? #97

romanr opened this issue Mar 31, 2018 · 1 comment

Comments

@romanr
Copy link

romanr commented Mar 31, 2018

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?

@varqasim
Copy link

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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants