vite react-ts에서 emotion css prop 쓰기

vite.config.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
import { defineConfig } from 'vite';
import react from '@vitejs/plugin-react';

// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react({
jsxImportSource: '@emotion/react',
babel: {
plugins: ['@emotion/babel-plugin'],
},
}),
],
});
tsconfig.json
1
2
3
4
5
6
{
"compilerOptions": {
// ...
"jsxImportSource": "@emotion/react"
}
}

참고

emotion css prop

terminal
1
2
yarn add @emotion/css @emotion/react @emotion/babel-preset-css-prop
yarn add -D react-app-rewired customize-cra
tsconfig.json
1
2
3
4
5
6
{
"compilerOptions": {
// ...
"jsxImportSource": "@emotion/react"
}
}
  • jsx 엘리먼트에서 css 속성을 사용할 수 있다

참고