Skip to content

itsMapleLeaf/vite-plugin-babel-macros

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

45 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

vite-plugin-babel-macros

Use babel macros in your Vite project!

Install

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(),
	],
}

Usage with @vitejs/plugin-react

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(),
	],
}