Emotion 11 uses @emotion/react instead of @emotion/core, which causes failure for gatsby-plugin-emotion.
Here's a workaround while gatsby-plugin-emotion gets updated:
Assuming you've already updated @emotion/react and @emotion/styled to v11:
gatsby-plugin-emotion from your gatsby-config.js.babelrc in the project root with the following contents:// .babelrc
{
"presets": [
[
"babel-preset-gatsby",
{
"targets": {
"browsers": [">0.25%", "not dead"]
}
}
]
],
"plugins": [
["@babel/plugin-proposal-decorators", { "legacy": true }],
[
"@emotion/babel-plugin-jsx-pragmatic",
{
"export": "jsx",
"import": "__cssprop",
"module": "@emotion/react"
}
],
[
"@babel/plugin-transform-react-jsx",
{
"pragma": "__cssprop",
"pragmaFrag": "React.Fragment"
}
]
]
}
npm i -D @babel/plugin-proposal-decorators @emotion/babel-plugin-jsx-pragmatic
I'm not sure why/if we need @babel/plugin-proposal-decorators, but it looks required in "How to use a custom .babelrc file"
Duplicate of https://github.com/gatsbyjs/gatsby/issues/28063
Most helpful comment
Here's a workaround while
gatsby-plugin-emotiongets updated:Assuming you've already updated
@emotion/reactand@emotion/styledto v11:gatsby-plugin-emotionfrom yourgatsby-config.js.babelrcin the project root with the following contents:I'm not sure why/if we need
@babel/plugin-proposal-decorators, but it looks required in "How to use a custom .babelrc file"