STUDY/Trouble Shooting๐จ
[React + Vite] Uncaught ReferenceError: regeneratorRuntime is not defined
JUNGY00N
2023. 10. 31. 15:58
ํด๋น ์๋ฌ๋ ๋น๋๊ธฐ ํต์ ์ ํ ๋ ์ฃผ๋ก ๋ํ๋๋ ์ค๋ฅ๋ผ๊ณ ํ๋ค.
๋ค๋ฅธ ํด๊ฒฐ๋ฐฉ๋ฒ๋ค์ ์๋ํ๋๋ฐ, ์ด๋ฒ ํ๋ก์ ํธ๋ vite๋ก ํ ํ๋ก์ ํธ์ฌ์ babel.config.js ์ค์ ์ด ๋จนํ์ง ์์๋ค.
์๋์ฒ๋ผ ํ๋ ํด๊ฒฐ !
npm install vite-plugin-babel @vitejs/plugin-legacy
// vite.config.js
import { defineConfig } from 'vite'
import react from '@vitejs/plugin-react'
import legacy from '@vitejs/plugin-legacy'
import babel from 'vite-plugin-babel'
// https://vitejs.dev/config/
export default defineConfig({
plugins: [
react(),
legacy({
targets: ['defaults', 'not IE 11'],
additionalLegacyPolyfills: ['regenerator-runtime/runtime'],
}),
babel({
babelConfig: {
babelrc: false,
configFile: false,
plugins: ['@babel/plugin-transform-runtime'],
}
})
],
})