1function importAll(r) {
2 let images = {};
3 r.keys().map((item, index) => { images[item.replace('./', '')] = r(item); });
4 return images;
5}
6
7const images = importAll(require.context('./images', false, /\.(png|jpe?g|svg)$/));
8
9<img src={images['doggy.png']} />
10