I use Webpack 5 and have no font section in “rules” and I see it put fonts files with hashed names into /dist folder and write this into result css: src: url(file:///C:/54b9eb90d4b941f9371e.woff2) format("woff2");
.
Webpack output says:
asset 9d060ce65c8a91d38e21.woff 50.5 KiB [emitted] [immutable] [from: src/common/fonts/ProximaNova/ProximaNova-Semibold.woff]
asset 54b9eb90d4b941f9371e.woff2 33 KiB [emitted] [immutable] [from: src/common/fonts/ProximaNova/ProximaNova-Semibold.woff2]
Even if I add font rule it still has this absolute path file:///C:/ no matter what I specify in filename
or publicPath
. For instance, in this case it just output to src: url(file:///C:/fonts/fonts/ProximaNova-Semibold.woff2) format("woff2")
:
{
test: /.(woff|woff2|eot|ttf|otf)$/i,
type: 'asset',
generator: {
filename: 'fonts/[name][ext]',
publicPath: '/fonts/',
},
}