babel-plugin-react-remove-classname

raw JSON →
1.0.0 verified Sat Apr 25 auth: no javascript

A Babel plugin (v1.0.0, last updated 2018) that removes CSS class names from JSX className attributes based on a configurable prefix (default "test-"). Useful for stripping test-only classes in production builds. Minimal configuration, no dependencies. Works with Babel 7 (v1.x) and Babel 6 (v0.x).

error Error: Cannot find module 'babel-plugin-react-remove-classname'
cause Plugin not installed or not in node_modules.
fix
Run npm install --save-dev babel-plugin-react-remove-classname
error ReferenceError: [BABEL] unknown: Unknown option: .prefix
cause Incorrect configuration format in .babelrc.
fix
Use array syntax: ["react-remove-classname", { "prefix": "custom-" }]
breaking v1.0.0 drops support for Node.js <6 and requires Babel 7.
fix Upgrade to Babel 7 and Node.js >=6, and update .babelrc to use 'react-remove-classname' (no babel-plugin- prefix) for Babel 7.
npm install babel-plugin-react-remove-classname
yarn add babel-plugin-react-remove-classname
pnpm add babel-plugin-react-remove-classname

Configure Babel to remove class names starting with 'test-' from JSX className attributes.

// .babelrc
{
  "plugins": [
    ["react-remove-classname", { "prefix": "test-" }]
  ]
}

// Input: <div className="test-a hello test-b"></div>
// Output: <div className="hello"></div>