New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
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

  • 2.0.1
  • latest
  • Source
  • npm
  • Socket score

Version published
Maintainers
1
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

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

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc