I am writing a Pug dependency loader. Essentially, it just produces an identical Pug file, except that the calls require()
will be replaced with the path to the file that they need. Obviously, so I need to take this path and pass it to the Webpack loader chain so that it can be processed in any way. using file-loader
to copy the image file to the appropriate location.
Everything works except this part. I cannot figure out how to pass the path to Webpack for download. To be clear, I want this to happen when you have require()
a file in your Webpack login file — Webpack must go through it, launch it through the list of possible loaders, and process it accordingly.
I tried using only the call require()
, I tried this.resolve()
and this.loadModule()
but no one worked. Since it this.resolve()
takes context as the first argument, I carefully gave it the appropriate context for my folder /src
. The image is in /src/images/image.jpeg
, and yet it actually gives an error that it cannot resolve this path, even if it is correct, so I'm not sure what I am doing wrong or how to do it.
source
share