Currently I have 3 fonts that I want to add to my React project:a, a light, a bold.
My file structure:
/src
├── /fonts/
│ ├── /A.ttf
│ ├── /A-
Webpack requires a font loader to load font files present in your project. you are using a file loader to load fonts. Change
{
test: /\.(ttf|eot|woff|woff2)$/,
loader: 'file-loader',
options: {
name: 'fonts/[name].[ext]'
}
to
{
test: /\.ttf$/,
use: [
{
loader: 'ttf-loader',
options: {
name: './font/[hash].[ext]',
},
},
]
}
by installing a font loader in your project like TTF Loader from NPM.