Socket
Socket
Sign inDemoInstall

babel-plugin-inline-classnames

Package Overview
Dependencies
52
Maintainers
1
Versions
14
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    babel-plugin-inline-classnames

Babel plugin which inlines the result of classnames


Version published
Weekly downloads
1.6K
increased by707.81%
Maintainers
1
Install size
14.9 kB
Created
Weekly downloads
 

Changelog

Source

2.0.1 (2019-01-26)

Bug Fixes

  • Guard before accessing VariableDeclarator init (#4) :bug: (92d6bc8)

<a name="2.0.0"></a>

Readme

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

FAQs

Last updated on 26 Jan 2019

Did you know?

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc