Recently I've upgraded my Webpack 4 project to version 5 and stumbled on an issue with file-loader
. For some reason fonts are generated in root directory instead of /fonts
.
{
test: /\.(woff(2)?|ttf|eot)(\?v=\d+\.\d+\.\d+)?$/,
use: info => {
const theme = path.basename(info.issuer, path.extname(info.issuer));
return [{
loader: 'file-loader',
options: {
name: '[name]_[hash].[ext]',
outputPath: url => path.join('root/link/to/theme', theme, 'dist/fonts', url),
publicPath: '../fonts'
}
}];
}
},
I've found one almost an answer Webpack 5: file-loader generates a copy of fonts with hash-name. However, problem is -- I need to generate multiple outputPaths
and not only one, In which case the generator
approach doesn't seem to be the right solution.
Any thoughts? Big thanks for help.
packages:
"webpack": "5.52.1",
"webpack-cli": "^4.10.0",