# @macro-plugin/vite

> Macro plugins integration for vite

Latest version **1.2.2** (published 2023-06-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install @macro-plugin/vite
pnpm add @macro-plugin/vite
yarn add @macro-plugin/vite
bun add @macro-plugin/vite
```

## Health

**Score 25/100 (F)** — status: abandoned.

Positive: has types; esm support; no vulnerabilities.

Warnings: low downloads.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.2.2 |
| Published | 2023-06-16 |
| First published | 2023-04-20 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Dependencies | 2 |
| Unpacked size | 16.9 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 16 |
| Author | Raven Satir |
| Maintainers | voorjaar |
| Keywords | vite, vitejs, vite-plugin, macro, macro-plugin |

## Links

- npm: https://www.npmjs.com/package/@macro-plugin/vite
- Repository: https://github.com/macro-plugin/macros
- Homepage: https://github.com/macro-plugin/macros/tree/main/packages/vite
- Issues: https://github.com/macro-plugin/macros/issues
- npm.io page: https://npm.io/package/@macro-plugin/vite

## Dependencies (2)

- [@macro-plugin/core](https://npm.io/package/@macro-plugin/core.md) 1.2.0
- [@macro-plugin/shared](https://npm.io/package/@macro-plugin/shared.md) 1.2.1

## Alternatives

- [raw-loader](https://npm.io/package/raw-loader.md) — 4.3M weekly downloads
- [plop](https://npm.io/package/plop.md) — 1.4M weekly downloads
- [webpack-deadcode-plugin](https://npm.io/package/webpack-deadcode-plugin.md) — 80.3K weekly downloads
- [@storybook/preact-vite](https://npm.io/package/@storybook/preact-vite.md) — 54.2K weekly downloads
- [vite-plugin-transform](https://npm.io/package/vite-plugin-transform.md) — 2.4K weekly downloads

## Recent versions

- 1.2.2 (latest) — 2023-06-16
- 1.2.1 — 2023-05-08
- 1.2.0 — 2023-05-03
- 1.1.0 — 2023-05-02
- 1.0.5 — 2023-04-27
- 1.0.4 — 2023-04-27
- 1.0.3 — 2023-04-24
- 1.0.2 — 2023-04-23
- 1.0.1 — 2023-04-22
- 1.0.0 — 2023-04-20

## README

# @macro-plugin/vite

[Macro Plugin](https://github.com/macro-plugin) integration for vite. It supports transform macros and typescript and also jsx.

## Installation

```sh
# if you use npm
npm i -D @macro-plugin/vite
# if you use pnpm
pnpm i -D @macro-plugin/vite
# if you use yarn
yarn add -D @macro-plugin/vite
```

## Usage

`vite.config.js`:

```js
import { defineConfig } from "vite"
import macroPlugin from "@macro-plugin/vite"

export default defineConfig({
  input: "src/index.js",
  output: {
    file: "dist/index.js",
    format: "es"
  },
  plugins: [
    macroPlugin()
  ]
})
```

It will load the configuration from `macros.config.js` or `macros.config.ts` by default. You can also customize it:

```js
import { defineConfig } from "vite"
import macroPlugin from "@macro-plugin/vite"

export default defineConfig({
  input: "src/index.ts",
  output: {
    file: "dist/index.js",
    format: "es"
  },
  plugins: [
    macroPlugin({ emitDts: true })
  ]
})
```

`macros.config.ts`:

```js
import { defineConfig } from "@macro-plugin/core"

export default defineConfig({
  macros: [],
  emitDts: true,
  jsc: {
    parser: {
      syntax: "typescript"
    },
    target: "esnext",
  },
})
```

Or with commonjs

`macros.config.js`

```js
/** @type {import("@macro-plugin/core").Config} */
module.exports = {
  macros: [],
  emitDts: true,
  jsc: {
    parser: {
      syntax: "typescript"
    },
    target: "esnext",
  },
}
```

## License

MIT

[MacroPlugin]: https://github.com/macro-plugin

---
_Source: https://npm.io/package/@macro-plugin/vite · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
