How to add fonts to create-react-app based projects?

前端 未结 7 1782
长情又很酷
长情又很酷 2020-11-29 15:19

I\'m using create-react-app and prefer not to eject.

It\'s not clear where fonts imported via @font-face and loaded locally should go.

Namely,

7条回答
  •  旧时难觅i
    2020-11-29 16:05

    You can use the WebFont module, which greatly simplifies the process.

    render(){
      webfont.load({
         custom: {
           families: ['MyFont'],
           urls: ['/fonts/MyFont.woff']
         }
      });
      return (
        
    your text!
    ); }

提交回复
热议问题