Description
Bug report
Actual Behavior
For begin I set a publicPath for my assets (ex fonts) :
test: /\.(eot|ttf|otf|woff|woff2)$/i,
type: 'asset/resource',
generator: {
publicPath: '/dist/fonts/',
outputPath: './fonts/',
},
When I set no subfolder for my css files it's work fine :
new MiniCssExtractPlugin({filename: "[name].css"}),
And I got the right path in my css files :
@font-face
{
font-family: 'Poppins';
src: url(/dist/fonts/3bd71aafa4de4b4a8875.eot);
src: url(/dist/fonts/3bd71aafa4de4b4a8875.eot?#iefix) format('embedded-opentype'),
url(/dist/fonts/e9b88d1590baa248f3e2.woff2) format('woff2'),
url(/dist/fonts/081fa188b65fb4393803.woff) format('woff'),
url(/dist/fonts/5c210093630fe230c462.ttf) format('truetype');
font-weight: 300;
font-style: normal;
}
But now if I want to put my css files into a subfolder like css/myfiles.css
:
new MiniCssExtractPlugin({filename: "css/[name].css"}),
I get wrong path in my css files :
@font-face
{
font-family: 'Poppins';
src: url(..//dist/fonts/3bd71aafa4de4b4a8875.eot);
src: url(..//dist/fonts/3bd71aafa4de4b4a8875.eot?#iefix) format('embedded-opentype'),
url(..//dist/fonts/e9b88d1590baa248f3e2.woff2) format('woff2'),
url(..//dist/fonts/081fa188b65fb4393803.woff) format('woff'),
url(..//dist/fonts/5c210093630fe230c462.ttf) format('truetype');
font-weight: 300;
font-style: normal;
}
Expected Behavior
When I use subfolder for my css files the path of my fonts inside my css files must be only /dist/fonts/
, but actually ../
are added in addition.
Please paste the results of npx webpack-cli info
here, and mention other relevant information
System:
OS: Linux 4.4 Debian GNU/Linux 10 (buster) 10 (buster)
CPU: (8) x64 Intel(R) Core(TM) i7-7700HQ CPU @ 2.80GHz
Memory: 8.02 GB / 15.89 GB
Binaries:
Node: 18.12.1 - ~/.nvm/versions/node/v18.12.1/bin/node
npm: 9.2.0 - ~/.nvm/versions/node/v18.12.1/bin/npm
Packages:
@webpack-cli/generators: ^3.0.1 => 3.0.1
babel-loader: ^9.1.0 => 9.1.0
copy-webpack-plugin: ^11.0.0 => 11.0.0
css-loader: ^6.7.3 => 6.7.3
html-webpack-plugin: ^5.5.0 => 5.5.0
style-loader: ^3.3.1 => 3.3.1
terser-webpack-plugin: ^5.3.6 => 5.3.6
webpack: ^5.75.0 => 5.75.0
webpack-cli: ^5.0.1 => 5.0.1
webpack-dev-server: ^4.11.1 => 4.11.1
webpack-manifest-plugin: ^5.0.0 => 5.0.0
workbox-webpack-plugin: ^6.5.4 => 6.5.4
Global Packages:
webpack-cli: 5.0.1
webpack: 5.75.0
Thanks