I have a preloader that takes an array of image URLs and starts loading the files as soon as my app is opened. Every time I use require() on an image I would like webpack to add that image's URL to the array that my preloader will be using.
My first inclination is to create a new loader to chain together with file-loader (which I'm currently using for images). The new loader would keep track of my images and save them to a JS file in the form of an array, which my preloader would import. But I realize that probably won't work because the preloader would have a dependency on a file that is generated at build time.
My stop gap solution is to build the project once, generate the array from the resulting image directory, copy it back into the preloader, and build again.
I have a feeling there's a better approach that I'm neglecting, and I'm looking for recommendations.