Roots Discourse

No /fonts/ in dist after compiling

sage9
#1

Hi,

First project using Roots 9 and just getting to grip with the new theme / framework.

I’m having issues with getting my /assets/fonts/ files compiling.

I run yarn build fine, it loads the font-face in the SCSS with correct paths, but the fonts don’t show in the front-end. On investigation, I can see there is no ‘/dist/fonts’ folder after compilation.

Where can I ensure this gets added in /dist/ compilation - it has 20 font files in the folder (i.e not empty), but /fonts/ doesn’t get added into /dist. Is there an extra step I’m missing? So I need to add /fonts/ somewhere in the theme to be included in /dist?

Thanks!

0 Likes

#2

Are the fonts used in your styles?

0 Likes

#3

Yes, it’s referenced in the @font-face setting and in styles.

0 Likes

#4

Fixed this - it was a path/to/webfont from CSS error.

0 Likes

listed #6
0 Likes

#7

For clarity and for anyone else who might run into this issue, do you mind writing out how you solved this? I think this could really help future users of this forum.

0 Likes

#8

I just started with Sage also and found myself in the exact situation. Loaded fonts into assets/fonts/ and had copied a font-face mixin from someone. I fixed my path problem by setting two things:

  1. traveling up once to reach fonts/ (e,g, ../fonts/Lato/Lato-Regular.ttf)
  2. wrapping the relative path in the url() function (e.g. url('../fonts/Lato/Lato-Regular.ttf'))

Webpack then identified the font dependency and created fonts/ in the dist build.

0 Likes