百科.dev
全部条目在线工具AI 编程趋势榜开源项目技术资讯提交条目
登录
< 返回工具列表
B

babel-plugin-react-remove-properties

> 前端框架
开源

用于删除 React 属性的 Babel 插件。 :dash:

382 stars0 点赞3 次浏览
访问官网GitHub

工具介绍

用于删除 React 属性的 Babel 插件。 :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 开放

查看全部 Issues在 GitHub 打开

暂无开放 Issues,或尚未同步最近议题。

> 标签

JavaScriptbabelbabel-pluginminificationproperties

暂无评论,来聊聊你的看法吧

> 工具信息

发布日期2026年8月1日
最后更新2026年9月17日
分类前端框架
定价开源

> 相关工具

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