-
Notifications
You must be signed in to change notification settings - Fork 10.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Clarify in tutorial that can load global CSS by importing css file #2956
Comments
This might be a bit out of scope for this issue, but I'd love to help others understand their choices with typography in CSS. The docs present two ways to customize typography: Webpack file loading and Typography.js. But I find myself most often just using your Typefaces project—it works really well! It's way more performant than the |
@benforshey Thanks for the heads up. I also self hosted mys sites fonts, but did so through this site. |
It's an awesome project, but it's not "more performant than the I could do a PR with an example site using Typefaces, but it's implementation in Gatsby isn't anything special: just import a font into your layout file, and then use it in your CSS. As a sidenote, I couldn't figure out how to implement Typefaces within Storybook within Gatsby, but I haven't spent much time on it either. |
@kildareflare Which font are you using from Google Fonts? Chances are, you can already use it via NPM via Typefaces. The list of current supported fonts are @ https://github.com/KyleAMathews/typefaces/tree/master/packages |
@dustinhorton Yup it is supported, thanks. I only did not use npm as did not realise it was an option. I'll be updating soon. |
Hmm, I'm puzzled. I personally found using Typefaces over my globally-imported |
So, it's not that I think using Typefaces is magic, but I figured that it was more performant because of code-splitting and bundling...all that good Webpack / Gatsby stuff that happens out of the box. But, admittedly, I'm still learning. |
For v1 we should also cover the default postcss plugins included, like cssnext, import, etc |
@benforshey curious why you say typography.js is heavy? Also are you comparing a non-gatsby project to a gatsby one? Curious how a simple change would lead to 150kb diff. Which is huge for css. Perhaps your other method was pulling in extra stuff. One nice thing about Gatsby + typefaces is the font-face declarations are inlined which means the browser starts downloading the font files all that much earlier. |
Oh, well, maybe heavy isn’t the right choice of words? I think Typography.js includes modernizer and default styles that I end up overwriting. I usually only use a CSS reset and some basic responsive typography rules. I remember running a PageSpeed Insights test using Typography.js and getting dinged for having a blocking CSS resource. No, it’s a Gatsby to Gatsby comparison. I’m really curious about my 150k, too, because it seems like my experience is pretty abnormal. Maybe it had something to do with the only Latin glyphs being used in Typefaces fonts (at least I think I saw that in the docs...)? I was including 6-or-so font files in the font-face declarations, with Woff, Woff2, etc. |
By the way, I don’t mean to derail the issue or cause a huge dustup over what I experienced. Maybe I screwed something up in my testing. I’ve screwed up simpler things. :-) I’m just trying to say that I’d be happy to help write (or at least be glad to see) Typfaces in the docs. Also, thanks so very much for your work on this stuff—I’m quite literally using it to earn a living. Your work + the community’s contribution is an invaluable resource to me. |
@benforshey coooool! That's what we're all working for! |
@KyleAMathews @dustinhorton If it's helpful to anything, I just reproduced the page size increase that I was talking about. Without I have a my master branch (Typefaces) and a branch preview ( Please let me know if there's anything I can do to help with this. I'd love to chip in somehow. |
@benforshey If you want to toss it in a public repo with a branch with & branch without Typefaces, I'd could take a look and try to debug. |
Hi all I would be happy to take a crack at updating the tutorial and/or adding any new examples. I import a css file in https://github.com/gatsbyjs/gatsby/tree/master/examples/using-redirects and could pull that out into a wider css example with other uses or separate them into distinct css examples or update existing ones. I am going to try to commit another example using all the netlify redirection options soon as well, So no biggie to add a couple more examples or tweak tutorial in the same pass. |
@dustinhorton Thanks! I just made a new gatsby-starter-default and put it into a public repo. The |
@benforshey |
@benforshey oh nevermind I see what you meant they do get moved to |
@benforshey That said, here are my results building both branches, only 8.909 kB difference in
|
@benforshey Also only the |
@rdela Ah, sorry about that. I forgot the Once I fixed that, I couldn't get I ran
I suspect that is just because I didn't actually require the files. Once I fixed that, my file sizes between branches were still relatively significant. Here are my processes and results: master
typefaces
So the difference in the two static folders, which in my tests only contain the font files, is 492K. So, I don't know why, or if I'm doing something wrong...but that's what I've got. |
@benforshey CORS problem related to #2960 I think, thanks for updating branch, when we get CORS 0.0.0.0/localhost issue resolved I will update my clone and we can resume font-face testing and trying to figure out why you are seeing such a big discrepancy. I will |
I'm self-hosting fonts and getting the same error as @benforshey when testing my project on the local network.
@rdela My packages are up-to-date. Is there any fix for this? |
@monsieurnebo upgrade to the latest. @m-allanson wrote a PR to fix your problem in #3299 |
@KyleAMathews I just tested |
@monsieurnebo You should not need
more background: #2960 (comment) & later comments and references on that issue. |
updated above and below |
Got this working without updating Gatsby. Think firewall or router was blocking something that made local network testing impossible. Only error I have is |
|
|
#1975 should provide a fix for the |
Nice thanks @m-allanson @pwener let me know if I can help out |
I updated to the latest and tested to use my real IP address as the following:
It fixes the CORS errors, but not these two:
That only shows up when accessing to the project from something else than Either way, we're using a npm command to start the local server, and we cannot hardcode the IP address so ... so I'm still trying to enable a |
👍 for documenting global CSS as a first-class citizen. I'm coming to Gatsby from a web components background and am all-in on CSS variables for global styles rather than typography.js style approaches, using CSS modules / styled components just for encapsulating component styles, as a replacement for shadow dom. Re: typography - I'd also echo including more standards-based approaches to performant type in docs, rather than leading with typography.js. Maybe even brief mentions of stuff like the font loading API / |
Due to the high volume of issues, we're closing out older ones without recent activity. Please open a new issue if you need help! |
Also add "CSS FAQ" that covers
The text was updated successfully, but these errors were encountered: