tfrommen / babel-plugin-classnames

Never import classnames again! Converts arrays of classnames to a call of a function of your choice.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

babel-plugin-classnames for JSX

Build Status

Never import classnames again! Converts arrays of classnames to a call of a function of your choice.

<div className={['btn', props.large && 'large']} />

đź’«

import _classNames from 'classnames'

<div className={_classNames('btn', props.large && 'large')} />

By default imports from classname. However the package name is configurable.

installation

npm i --save-dev babel-plugin-classnames

Then add the plugin to your .babelrc file:

{
  "plugins": [
    "@babel/plugin-syntax-jsx",
    "babel-plugin-classnames"
  ]
}

Configuring the package name

You can set the package name by defining the packageName options:

{
  "plugins": [
    ["babel-plugin-classnames", { "packageName": "dss-classname" }]
  ]
}

About

Never import classnames again! Converts arrays of classnames to a call of a function of your choice.

License:MIT License


Languages

Language:JavaScript 100.0%