Skip to content
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

import external fonts is broken in 3.2.0 #1574

Closed
piuccio opened this issue Mar 6, 2018 · 4 comments
Closed

import external fonts is broken in 3.2.0 #1574

piuccio opened this issue Mar 6, 2018 · 4 comments
Assignees
Labels

Comments

@piuccio
Copy link

piuccio commented Mar 6, 2018

Version

styled-components: 3.2.0
babel-plugin-styled-components: 1.5.1

Reproduction

Sorry I tried to reproduce it here but it works fine, however you can see the issue on this repo it's a clone of react-boilerplate.

There's a file called global-styles.js that injects global CSS, including the following

import { injectGlobal } from 'styled-components';

/* eslint no-unused-expressions: 0 */
injectGlobal`
  @import url(https://fonts.googleapis.com/earlyaccess/notosansjapanese.css);
`

Steps to reproduce

npm install with styled-component 3.2.0 and npm start it'll load a local server. Inspect the styles and you'll see that Noto Sans is not used.

Kill the server, change package.json to 3.1.6, npm install && npm start and the fonts are now Noto Sans

Expected Behavior

Always use Noto Sans

screen shot 2018-03-06 at 11 24 38

Actual Behavior

Uses fallback font

screen shot 2018-03-06 at 11 25 34

@kitten kitten added the bug 🐛 label Mar 6, 2018
@kitten kitten self-assigned this Mar 6, 2018
@kitten
Copy link
Member

kitten commented Mar 6, 2018

It is in fact reproducible: https://codesandbox.io/s/6wk63nr91n

It seems that I've forgotten to port over some exceptions for @import in the migration.

Unfortunately I think it'll be tough to make this work in tandem with #1493, as the @import rules need to be at the beginning of the stylesheet, but at the same time we need to be able to remove them at any time.

Edit: For now, I think it'd be best if you pull out your @import into a <link> element

cc @mxstbr @probablyup

@mxstbr
Copy link
Member

mxstbr commented Mar 6, 2018

Oh damn, we really need to fix this.

@kitten
Copy link
Member

kitten commented Mar 6, 2018

@piuccio Can you help me to test out a prerelease that addresses this bug please? It's published as styled-components@dev version 3.2.1-0. It's from the PR referenced above and seems to fix the problem in the CodeSandbox, where I reproduced the bug, just fine: https://codesandbox.io/s/v6v6r73j37

@piuccio
Copy link
Author

piuccio commented Mar 7, 2018

@kitten I tested 3.2.1-2 and it works fine. Thanks for the quick fix

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants