Gem 一覧へ戻る
Babel plugin for removing React properties. :dash:
- star 数
- 383
- watcher 数
- 6
- fork 数
- 19
- issue 数
- 0
- 最終更新
- 2025/09/21
Babel plugin for removing React properties. :dash:
Babel plugin for removing React properties.
npm install --save-dev babel-plugin-react-remove-properties
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.
In
class Foo extends React.Component { render() { return ( <div className="bar" data-test="thisIsASelectorForSelenium"> Hello Wold! </div> ); } }
Out
class Foo extends React.Component { render() { return ( <div className="bar"> Hello Wold! </div> ); } }
.babelrc
without options:
{
"env": {
"production": {
"plugins": [
"react-remove-properties"
]
}
}
}with options. We accepts an array of property names that can be either strings or regular expressions:
{
"env": {
"production": {
"plugins": [
["react-remove-properties", {"properties": ["data-test", "data-foo", /my-suffix-expression$/]}]
]
}
}
}babel --plugins react-remove-properties script.js
without options:
require('babel-core').transform('code', { plugins: [ 'react-remove-properties', ], });
with options:
require('babel-core').transform('code', { plugins: [ ['react-remove-properties', {properties: ['data-test', 'data-foo', /my-suffix-expression$/]}], ], });
MIT