Preloading assets with webpack

I have a preloader that takes an array of image URLs and starts downloading files immediately after opening my application. Every time I use require () on an image, I would like webpack to add this image URL to the array that my preloader will use.

My first slant is to create a new downloader to merge with the file downloader (which I am currently using for images). The new bootloader will track my images and save them in a JS file as an array, which my preloader will import. But I understand that it probably won’t work, because the preloader will depend on the file that is created during the build.

My solution to stopping the break is to build the project once, generate an array from the resulting image catalog, copy it back to the preloader and create it again.

I have a feeling that there is a better approach that I ignore, and I am looking for recommendations.

+7
webpack preload
source share

No one has answered this question yet.

See similar questions:

eleven
Webpack plugin: how can I change and reassemble a module after compilation?

or similar:

1203
NPM vs. Bower vs. Browserify vs. Gulp vs. Grunt vs. Webpack
192
Import ES6 using ('@') path entry in vue.js project using Webpack
126
How to bundle vendor scripts separately and require them as needed using Webpack?
66
Dynamically Add React Webpack Images
24
Best way to preload images with Angular.js
8
Webpack loader splitter circuits for the same file type
6
How do I (or should I) extend the version of Modernizr.load () to preload images?
one
webpack does not load image as element background
one
image url / path for use with webpack in css?
0
Ejs Webpack bootloader with img balises

All Articles