https://github.com/giuseppeg/babel-plugin-classnames
Never import classnames again! Converts arrays of classnames to a function call of your choice.
https://github.com/giuseppeg/babel-plugin-classnames
Last synced: about 1 year ago
JSON representation
Never import classnames again! Converts arrays of classnames to a function call of your choice.
- Host: GitHub
- URL: https://github.com/giuseppeg/babel-plugin-classnames
- Owner: giuseppeg
- License: mit
- Created: 2018-05-31T14:57:21.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2021-08-11T04:25:32.000Z (almost 5 years ago)
- Last Synced: 2025-04-30T07:31:07.995Z (over 1 year ago)
- Language: JavaScript
- Homepage:
- Size: 38.1 KB
- Stars: 80
- Watchers: 3
- Forks: 11
- Open Issues: 4
-
Metadata Files:
- Readme: README.md
- Funding: .github/FUNDING.yml
- License: LICENSE.md
Awesome Lists containing this project
README
# babel-plugin-classnames for JSX
[](https://travis-ci.org/giuseppeg/babel-plugin-classnames)
Never import classnames again! Converts arrays of classnames to a call of a function of your choice.
```js
```
💫
```js
import _classNames from 'classnames'
```
By default imports from `classnames`. However the package name is configurable.
## Installation
```
npm i --save-dev babel-plugin-classnames
```
Then add the plugin to your `.babelrc` file:
```JSON
{
"plugins": [
"@babel/plugin-syntax-jsx",
"babel-plugin-classnames"
]
}
```
## Configuring the package and import name
You can set the package name by defining the `packageName` option:
```JSON
{
"plugins": [
["babel-plugin-classnames", { "packageName": "dss-classnames" }]
]
}
```
If the function you want to use is not the default package export you can use the `importName` option:
```JSON
{
"plugins": [
["babel-plugin-classnames", {
"packageName": "emotion",
"importName": "cx"
}]
]
}
```