Closed advaitju closed 5 years ago
Can you share an example URLs file?
Example URLs files.
module.exports = [
'./images/image1.jpg',
'./images/image2.jpg',
'./images/image3.jpg',
];
For now I've decided to do this - which achieves what I wanted. Dynamic imports would be nice to have, but I guess they're not needed for this particular use case.
import image1 from './images/image1.jpg';
import image2 from './images/image2.jpg';
import image3 from './images/image3.jpg';
module.exports = [
image1,
image2,
image3,
];
It would still be great to be able to import programatically if there are lots of images used in a grid/slider.
@advaitju I'll take a look ASAP.
I'd just use this babel plugin for this kind of thing:
I'd just use this babel plugin for this kind of thing:
Thanks Andrew, I didn't know about this particular plugin. I think it might solve this use case.
@advaitju Do you think this plugin solves your issue? If so, we can close this issue.
@advaitju Do you think this plugin solves your issue? If so, we can close this issue.
No worries, thanks for your help Aref. The plugin solves my problem.
I'm keeping images in an
images/
folder and URLs in a data file. I'd like to dynamically import the images so I can load a large number of images easily.I thought this could be done using dynamic imports, however it seems that functionality only supports Js modules. Will this be supported in the future or am I totally off the mark on this one?
I'm getting the error Error: Cannot find module.