Having trouble configuring webpack

It is necessary that the project was a dynamic HTML-page. It is better that it is rendered on the server. The framework itself: Adonis , but the standard template language in it is not so convenient ( edge files). Therefore, I decided to use Pug .

The structure of the project itself is as follows: there is a source folder, in it there are folders for each page / component. After the webpack build , everything gets in the right places: public and views .

Everything except pictures. I did not understand how to properly configure the webpack so that it does not compile pug in html and change the links in img src (in the case of JPG / JPEG / PNG it is image/[name].[ext] , and in the case of SVG - icon/[name].svg ).

And in general: is it correct to use pug in this way ?
Or is it better to use it only during the build?

Now I use the following method:
I add the pug file to the webpack using: html-webpack-plugin , then I use the html-webpack-pug-plugin to add link and script pug to the file.
As I understand it, you need to configure the loader , this design:

 { test: /\.pug$/, loaders: ['html-loader', 'pug-html-loader'] } 

It works, but I get a file with a default HTML template.

    1 answer 1

    The solution appeared: https://www.npmjs.com/package/pug-asset-loader With this plugin, you can process pug files using the pal(<PATH>) function pal(<PATH>) for the relative path that will be replaced after assembly.