An open API service indexing awesome lists of open source software.

https://github.com/ben-rogerson/babel-plugin-twin

Activate twin.macro’s tw prop without adding the twin import. A companion plugin for twin.
https://github.com/ben-rogerson/babel-plugin-twin

Last synced: 7 months ago
JSON representation

Activate twin.macro’s tw prop without adding the twin import. A companion plugin for twin.

Awesome Lists containing this project

README

          

# Babel plugin twin

Total Downloads
Latest Release
Discord

This plugin automatically adds the tw prop from [twin.macro](https://github.com/ben-rogerson/twin.macro) - no import required:

```diff
- import "twin.macro"

const Component = () =>


```

You’ll also get the css prop from your css-in-js library:

```diff
const Component = () =>


```

## Installation

```shell
npm i -D babel-plugin-twin
# or
yarn add babel-plugin-twin -D
```

Then add the plugin to your babel config:

```js
module.exports = {
plugins: [
"babel-plugin-twin",
"babel-plugin-macros",
// ...
],
};
```

Note: You must add `"babel-plugin-twin"` before `"babel-plugin-macros"` in the plugins array.

## Options

Add debug to your config to see some feedback:

```js
module.exports = {
plugins: [
["babel-plugin-twin", { debug: true }],
"babel-plugin-macros",
// ...
],
};
```

To avoid checking files or folders, supply `exclude` with an array of regex patterns:

```js
module.exports = {
plugins: [
["babel-plugin-twin", {
"exclude": [
"temp/",
"..."
]
},
"babel-plugin-macros",
// ...
],
};
```

## Special thanks

A big shoutout goes to [@euvs](https://github.com/euvs) for the plugin concept + code and [@mxsbr](https://github.com/mxstbr) for planting [the idea](https://github.com/ben-rogerson/twin.macro/issues/247).