vitejs / vite-plugin-react-swc

Speed up your Vite dev server with SWC
MIT License
781 stars 50 forks source link

support jsxImportSsource @emotion/react? #25

Closed Dimitri-WEI-Lingfeng closed 1 year ago

dchambers commented 1 year ago

It just so happens that @sanderdrummer created a branch to do exactly this (as a temporary work-around) just one hour after you created this issue ❤️ . What's even better he also published it to npm as plugin-react-swc-emotion.

Simply switch from @vitejs/plugin-react-swc to plugin-react-swc-emotion in your package.json, and then change the import statement in vite.config.ts to point to plugin-react-swc-emotion, like so:

import { defineConfig } from 'vite'
// TODO: revert to official `@vitejs/plugin-react-swc` once support for configuring `importSource` is added
import react from 'plugin-react-swc-emotion' // @ts-ignore

// https://vitejs.dev/config/
export default defineConfig({
  plugins: [react()],
})
ArnaudBarre commented 1 year ago

Sounds good for me. I will work on this later today