-
Notifications
You must be signed in to change notification settings - Fork 27k
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
CSS @import url for loading fonts doesnt work #30567
Comments
I have the same problem with Google Fonts, the exact same situation as described by @jaemil. With NextJs version 11.0.1 was working fine, and after upgrading to latest version the fonts are not loading correctly. I'm using Tailwind CSS and the import is found in globals.css and is also attached in the output file styles.css. The import:
|
I had the same problem with experimental: {
concurrentFeatures: true,
serverComponents: true,
// urlImports: []
} And try building again, works on both my ARM macOs and x64 Ubuntu...! |
Same issue with Typekit and Tailwind, but a different workaround: Instead of: /* base.css */
@import "https://use.typekit.net/*******.css"; This works for me: /* base.css */
@import "./fonts.css"; /* fonts.css */
@import "https://use.typekit.net/*******.css"; I need to take a nap thinking about why this works 🤯 |
Same here, I use TailwindCSS and in @tailwind base;
@tailwind components;
@tailwind utilities;
@layer base {
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@300;400;500;600;700&display=swap');
* {
box-sizing: border-box;
margin: 0;
padding: 0;
}
html,
body {
font-family: 'Poppins', sans-serif;
line-height: 1.8;
}
// ... I see in chrome inspector that computed font is the one I imported, but it doesn't render as should be On UPDATE:When I added |
@timneutkens I found the proximate cause: the
Sure enough, if I manually edit the chunk to put this Our source file does have the |
... never mind, that was my bad Github search-fu landing me in some really old code :) |
Adding a custom |
Yeah, the workaround of an explicit
Thanks to the other commenters here for the help! |
Including the So adding |
Are there any news or progress on this? |
@sveggiani It's to be released in the 12.0.4 milestone, which is scheduled for November 30. Shouldn't be too long now. |
Unfortunately, not fixed in Next 12.0.4 or 12.0.5 canary 3 |
Importing Typekit fonts is still broken for me in 12.0.7. Should this issue still be open? |
No. Please open a separate issue with a reproduction. |
There is a possibility that this is the same as #32645 |
What version of Next.js are you using?
12.0.1
What version of Node.js are you using?
17.0.1
What browser are you using?
Firefox, Chrome
What operating system are you using?
Windows 10
How are you deploying your application?
next start
Describe the Bug
App.scss:
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
Loading the font with next dev works but not with next build (next start).
Tested with
optimizeFonts: false
but with same result.Expected Behavior
In next 11.0.1 the font was imported correctly
To Reproduce
Inside App.scss
@import url('https://fonts.googleapis.com/css2?family=Poppins:wght@400;500;600;700&display=swap');
The text was updated successfully, but these errors were encountered: