GitXplorerGitXplorer
g

babel-plugin-classnames

public
80 stars
11 forks
4 issues

Commits

List of commits on branch master.
Verified
24861fe6c9af3c9d351b2472ea0d7b538c1ff018

FUNDING.yml

ggiuseppeg committed 5 years ago
Unverified
3cf317a98eae29348f9a653c2ff1812e1e65ca28

0.2.0

ggiuseppeg committed 6 years ago
Unverified
e91049a16cad2ee9f5f450ed50209b8bbf4e69ea

Add `importName` option to support non-default exports (#5)

bbradlc committed 6 years ago
Unverified
2609ac24a34eb1a1fa57d6d13b30576c5f71aadc

Do not reuse AST nodes (#4)

AAndarist committed 7 years ago
Unverified
ef026a4e110b6b5b020560c1a2c92c741c35ce8a

Fix typo in the packageName example (#2)

kkristerkari committed 7 years ago
Unverified
6077cc70d1d3bf9ea8687e5ebf8527a290384611

Indent curly bracket (#1)

ttfrommen committed 7 years ago

README

The README file for this repository.

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 classnames. 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 and import name

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

{
  "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:

{
  "plugins": [
    ["babel-plugin-classnames", {
      "packageName": "emotion",
      "importName": "cx"
    }]
  ]
}