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?
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.
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:
traveling up once to reach fonts/ (e,g, ../fonts/Lato/Lato-Regular.ttf)
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.
I’m experiencing this same problem. If anybody has any ideas or comments on how they fixed this I’d like to know.
I have fonts in my assets/fonts folder. These are referenced in my _font.scss partial (pulled into my main.scss above other partials using this).
I’m in the same boat guys, I managed to get /fonts directory compiled in /dist (with @ rybot help) but now when attempting to use the fonts in my SCSS files I just get the error Unexpected missing generic font family font-family-no-missing-generic-family-keyword
The fonts are compiled correctly in /dist and I use the following code from myfonts.com:
Hi Alwaysblank yes of course I read the error and searched on Google. I also searched on this forum but could only find another post relating to font awesome with no solution. I wasn’t able to get it working, so decided to post here for some help
I’d suggest that you did the right thing, @digitalmad (although, perhaps your question could’ve been in its own thread) - sometimes people can be a little patronising if you don’t understand or see something exactly as they do - but it is the internet, after all. Sage 9 and its tools can be a very steep learning curve so don’t get discouraged.
@alwaysblank’s message probably gets you as far as you’d already got, so to extend on that further - you simply have to add a “generic” font family, such as serif or sans-serif to your previous code - ie font-family: “TTNormsPro-Regular”, sans-serif;
Although, just looking back at your previous code - you’re defining the font rather than using it, so you can probably drop the generic font, but use it for when you call the font on an element.
So to be clear - your code above can probably stay as font-family: “TTNormsPro-Regular”; and then when you style an element it would be more like:
Yes, I just noticed that as well, your assistance with the generic font family solved the stytlint error but then the fonts were not loading. It would appear the generic font family should only be used on the selector and not the @font-face as well