New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

babel-plugin-inline-classnames

Package Overview
Dependencies
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

babel-plugin-inline-classnames

Babel plugin which inlines the result of classnames

latest
Source
npmnpm
Version
2.0.1
Version published
Weekly downloads
1.4K
39.76%
Maintainers
1
Weekly downloads
 
Created
Source

babel-plugin-inline-classnames

Travis branch NPM version

Babel plugin which inlines the result of classnames

Useful for production builds.

Install

npm:

npm install -S babel-plugin-inline-classnames

yarn:

yarn add babel-plugin-inline-classnames

Usage

Add this plugin to your Babel config. Most commonly used in .babelrc:

For all environments:

{
  "plugins": ["babel-plugin-inline-classnames"]
}

For production only (see env option):

{
  "env": {
    "production": {
      "plugins": ["babel-plugin-inline-classnames"]
    }
  }
}

Examples

Input:

import classNames from 'classnames';
import styles from './styles.css';

classNames('foo', 'bar');
classNames('foo', { bar: true });
classNames({ 'foo-bar': true });
classNames({ 'foo-bar': false });
classNames({ foo: true }, { bar: true });
classNames({ foo: true, bar: true });
classNames('foo', { bar: true, duck: false }, 'baz', { quux: true });
classNames(null, false, 'bar', undefined, 0, 1, { baz: null }, '');
classNames(styles.foo, styles.bar);

Output:

import styles from './styles.css';

'foo bar';
'foo bar';
'foo-bar';
'';
'foo bar';
'foo bar';
'foo bar baz quux';
'bar ' + 1;
(styles.foo || '') + ' ' + (styles.bar || '');

With bind:

import classNames from 'classnames/bind';
import styles from './styles.css';

const cx = classNames.bind(styles);

cx('foo', 'bar');

Output:

import styles from './styles.css';

(styles.foo || '') + ' ' + (styles.bar || '');

Versions

See full changelog for details.

  • 1.* - requires Babel 6.*
  • 2.* - requires Babel 7.*

Keywords

babel-plugin

FAQs

Package last updated on 26 Jan 2019

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts