Skip to content

add /** @jsxImportSource @emotion/react */ at the top of every file in my CRA project #13225

Closed Answered by TamirCode
TamirCode asked this question in Q&A
Discussion options

You must be logged in to vote

using CRACO:

npm i @emotion/react
npm i -D @emotion/babel-plugin @craco/craco

create at root of project (next to package.json) file called craco.config.js

module.exports = {
    babel: {
        presets: [
            [
                "@babel/preset-react",
                { "runtime": "automatic", "importSource": "@emotion/react" }
            ]
        ],
        plugins: ["@emotion/babel-plugin"]
    }
}

update scripts in package.json:

    "scripts": {
        "start": "craco start",
        "build": "craco build",
        "test": "craco test",
    },

for typescript CRA, make sure to include this in tsconfig inside compilerOptions

"jsx": "react-jsx",
"jsxImportSource": "@emotion/react"

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by TamirCode
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
1 participant