A Babel plugin that replaces classnames() calls with their string result at compile time. Current version 2.0.1 supports classnames up to v2.x and requires @babel/core 7.x. It inlines calls to classnames, classnames/bind, and classnames/dedupe. Useful for production builds to reduce bundle size and avoid runtime overhead. Unlike runtime-only solutions, this plugin eliminates the classnames library from the bundle entirely. Compatible with CSS Modules via the bind API. No active development since 2019, but stable and functional.
npm install babel-plugin-inline-classnamesVerified import paths — ran on the pinned version, not inferred.
Shows Babel configuration for production-only usage and how classnames calls are replaced with inline strings.
Ensure all arguments to classnames are literals or identifiers; dynamic objects may not be optimized.
Use version 1.x if on Babel 6, or upgrade to Babel 7.
Consider alternatives like babel-plugin-transform-classnames or manual inlining.
Check that all referenced style keys exist in the CSS module object.
Avoid using dedupe if you rely on deduplication; or handle duplicates separately.
Run 'npm install classnames' or 'yarn add classnames'.
Run 'npm install babel-plugin-inline-classnames --save-dev'.
Use 'import classNames from 'classnames/bind'; const cx = classNames.bind(styles);'