W
W
Worddoc2018-04-28 16:59:45
JavaScript
Worddoc, 2018-04-28 16:59:45

Why can't I connect fonts in create-react-app?

Hello!
The problem is this: I create a project through create-react-app, I put the fonts in src/fonts/, I write the following in App.css:

@font-face {
    font-family: 'Circe';
    src: url('./fonts/Circe-Regular.woff2') format('woff2'),
        url('./fonts/Circe-Regular.woff') format('woff'),
        url('./fonts/Circe-Regular.ttf') format('truetype');
    font-weight: 400;
    font-style: normal;
    font-display: swap;
}

And in the console it gives: Module not found: Can't resolve './fonts/Circe-Regular.ttf' in 'F:\web-dev\in-process\react-test\
Tell me why webpack does not see this font? Thank you.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
A
AlexSND, 2018-05-04
@AlexSND

I do this: the fonts folder contains the fonts.css file, and this file is imported into App
import “./fonts/fonts.css”

N
nordlander88, 2020-08-28
@nordlander88

the path to the font file is incorrect, you are already in the fonts directory

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question