How to handle import rules with emotion?

1.2k Views Asked by At

How to handle CSS @imports with Emotion? I have recently upgraded to version 11 and it emits following error:

`@import` rules can't be after other rules. Please put your `@import` rules before your other rules.

I have made sure that this is the first statement or first global inject in my code. My CSS code is:

import { injectGlobal } from '@emotion/css';

injectGlobal`

  /* Normalize the stylesheet */
  /* @import url('https://cdnjs.cloudflare.com/ajax/libs/normalize/8.0.1/normalize.min.css'); */

  /* Using typeface 'Sarabun' */
  @import url('https://fonts.googleapis.com/css2?family=Sarabun:ital,wght@0,300;0,400;0,500;0,600;0,700;0,800;1,300;1,400;1,500;1,600;1,700;1,800&display=swap');

  /* Using typeface 'Fira Code' for code snippets */
  @import url('https://fonts.googleapis.com/css2?family=Fira+Code:wght@300;400;500;600;700&display=swap');

  html,
  body {
    font-family: 'Sarabun', sans-serif;
    margin: 0;
    padding: 0;
  }

  pre {
    font-family: 'Fira Code', monospace;
    font-weight: 500;
  }
`;
0

There are 0 best solutions below