I'm using webpack and it's file-loader + html-loader to emit files into my output directory. It works almost as expected, because it also duplicates those files.
Here is a part of my webpack.config.js
file:
module.exports = {
module: {
rules: [
{ test: /\.html$/, use: ["html-loader"] },
{
test: /\.(jpg|png)$/,
use: {
loader: "file-loader",
options: {
name: "[name].[ext]",
outputPath: "img",
},
},
},
],
},
};
There is a small example of how my output directory looks like:
dist/
- img/
- img1.png
- img2.png
- ab0d12.png
- c3d612.png
- index.html
- bundle.js
The two images with hashed names are unwanted duplicates of those in img/
directory. As you can see in the example above, I'm not even setting the name to be hashed and I also cannot open the duplicate files in any way.
I'm using some plugins like HtmlWebpackPlugin
or CleanWebpackPlugin
, but I believe they are not causing the problem.
Versions:
- webpack
5.28.0
- file-loader
6.2.0
- html-loader
2.1.2
img1.png
andimg2.png
stored before bundling? – Califateimg/
dir inside thesrc/
dir. I'm importing them usingsrc
attribute:<img src="./img/img1.png">
. – Encaenia