I have a setup where I use webpack to compile a css-file that has a url-link to a png image. Both, css-file and png are written to the output folder using hashed names. I use css-loader, extract-loader and file-loader to achieve this.
The whole setup worked just fine with webpack v4 and css-loader v3.
Now I'm trying to migrate to webpack v5 and css-loader v5. With that the url-link in the generated css is wrong: It has an auto-prefix, e.g.
- The generated png:
logo.9941b604ef38475a0267fbba30e5b505.png - The url in the css:
url(autologo.9941b604ef38475a0267fbba30e5b505.png)
Is this behavior intended or is this a bug?
The versions I use:
webpack: 5.38.1
css-loader: 5.2.6
file-loader: 6.2.0
extract-loader: 5.1.0
My webpack.config.js
const path = require('path');
const distDir = path.resolve(__dirname, 'dist');
module.exports =
{
experiments:
{
asset: false
},
entry:
{
style: './src/style.js'
},
output:
{
filename: '[name].bundle.[contenthash].js',
path: distDir,
},
module:
{
rules:
[
{
resource: /\.css$/,
use:
[
{
loader: 'file-loader',
options:
{
name: '[name].[hash].css'
}
},
{
loader: 'extract-loader'
},
{
loader: 'css-loader'
}
],
},
{
test: /\.png$/,
use: {
loader: 'file-loader',
options: {
name: '[name].[hash].[ext]'
}
}
}
]
}
};
The style.js is just a dummy entry point where I simply import my css file.
Thanks for any feedback.