DimiMikadze/create-react-library

Font files not available

i-gk opened this issue · 4 comments

i-gk commented

Hello,

I have my font files within a fonts directory and these were referred by my scss files. However when I build the project, the dist does not have the fonts directory and throwing a not found error for the font file.

What should be the correct approach to get this fixed?

System

Node.js version: v12.18.2
NPM or Yarn version: npm 6.14.5
Operating system: Windows 10

Steps to reproduce

  1. Add fonts directory with couple of font files
  2. Refer them in your scss file
  3. try it from example dir

Hi @i-gk, where exactly are you adding your fonts directory? Try to add the fonts folder inside the src directory.

If it won't work, then probably you need to tweak Webpack's configuration.

i-gk commented

Hey @DimiMikadze yah it is inside the src. I was thinking the same, add a copy command to webpack. But wanted to check if there is built in support first.

@i-gk, I never tried it, but I think it should be built-in. This discussion should help you: https://stackoverflow.com/questions/41676054/how-to-add-fonts-to-create-react-app-based-projects

i-gk commented

Thank you! I tried this and did not work. Ended up writing a copy command for assets