Baike.dev
All toolsOnline toolsAI codingTrendingOpen sourceNewsSubmit
Log in
< Back to tools
B

babel-plugin-react-remove-properties

> 前端框架
Open source

Babel plugin for removing React properties. :dash:

382 stars0 likes3 views
WebsiteGitHub

About

Babel plugin for removing React properties. :dash:

babel-plugin-react-remove-properties

Babel plugin for removing React properties.

Installation

bash
npm install --save-dev babel-plugin-react-remove-properties

The problem solved

This is useful when using selectors like data-test to run selenium test. Those properties are useless when running the code in production. You can save bandwidth by removing them.

Example

In

javascript
class Foo extends React.Component {
  render() {
    return (
      

    );
  }
}

Out

javascript
class Foo extends React.Component {
  render() {
    return (
      

    );
  }
}

Usage

Via .babelrc (Recommended)

.babelrc

without options:

json
{
  "env": {
    "production": {
      "plugins": [
        "react-remove-properties"
      ]
    }
  }
}

with options. We accepts an array of property names that can be either strings or regular expressions:

json
{
  "env": {
    "production": {
      "plugins": [
        ["react-remove-properties", {"properties": ["data-test", "data-foo", /my-suffix-expression$/]}]
      ]
    }
  }
}

Via CLI

bash
babel --plugins react-remove-properties script.js

Via Node API

without options:

javascript
require('babel-core').transform('code', {
  plugins: [
    'react-remove-properties',
  ],
});

with options:

javascript
require('babel-core').transform('code', {
  plugins: [
    ['react-remove-properties', {properties: ['data-test', 'data-foo', /my-suffix-expression$/]}],
  ],
});

License

MIT

Issues· 0 open

View all issuesOpen on GitHub

No open issues yet, or sync has not completed.

> Tags

JavaScriptbabelbabel-pluginminificationproperties

No comments yet. Be the first to share.

> Details

PublishedAug 1, 2026
UpdatedSep 17, 2026
Category前端框架
PricingOpen source

> Related tools

R
React
用于构建用户界面的 JavaScript 库
V
Vue.js
渐进式 JavaScript 框架
N
Next.js
基于 React 的全栈 Web 框架