Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why are my GlobalStyles not working after deploying with styled components?

I'm using React, Redux, styled components and GitHub pages with my app.

Global styles work in development, but do not get applied after deploying to GitHub pages.

e.g. in App.js

import { createGlobalStyle } from 'styled-components';

const GlobalStyle = createGlobalStyle`
   body {
      @import url("https://fonts.googleapis.com/css?family=Quicksand");
      color: red;
   }
`

const App = () => (
   <React.Fragment>
      <GlobalStyle />
      <Provider store={store}>
         <Router>
            <div>
              //REST OF APP
            </div>
         </Router>
      </Provider>
   </React.Fragment>
);

export default App;
like image 344
Brendan Avatar asked Dec 30 '25 03:12

Brendan


1 Answers

The problem lies in the fact that there is currently an issue when using @import in Global Styles. The solution is to take the @import out and place it elsewhere, such as in a link tag, if you're using Google fonts.

like image 187
Brendan Avatar answered Dec 31 '25 18:12

Brendan