Use babel macros in your Vite project!
npm install --save-dev vite-plugin-babel-macros
Then, add it to your vite config:
import macros from "vite-plugin-babel-macros"
export default {
// ...
plugins: [
// ...
macros(),
],
}
Install babel-plugin-macros
, then add the plugin to the react plugin options.
npm install --save-dev babel-plugin-macros
import react from "@vitejs/plugin-react"
import macros from "vite-plugin-babel-macros"
export default {
// ...
plugins: [
// ...
react({
babel: {
plugins: ["babel-plugin-macros"],
},
}),
macros(),
],
}