Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/oliviertassinari/babel-plugin-react-remove-properties
Babel plugin for removing React properties. :dash:
https://github.com/oliviertassinari/babel-plugin-react-remove-properties
babel babel-plugin minification properties react
Last synced: 4 days ago
JSON representation
Babel plugin for removing React properties. :dash:
- Host: GitHub
- URL: https://github.com/oliviertassinari/babel-plugin-react-remove-properties
- Owner: oliviertassinari
- Created: 2015-10-18T12:48:25.000Z (over 9 years ago)
- Default Branch: master
- Last Pushed: 2019-03-15T00:33:20.000Z (almost 6 years ago)
- Last Synced: 2024-10-29T21:50:09.307Z (3 months ago)
- Topics: babel, babel-plugin, minification, properties, react
- Language: JavaScript
- Homepage:
- Size: 42 KB
- Stars: 379
- Watchers: 6
- Forks: 18
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
Awesome Lists containing this project
README
# babel-plugin-react-remove-properties
> Babel plugin for removing React properties.
[![npm version](https://img.shields.io/npm/v/babel-plugin-react-remove-properties.svg?style=flat-square)](https://www.npmjs.com/package/babel-plugin-react-remove-properties)
[![npm downloads](https://img.shields.io/npm/dm/babel-plugin-react-remove-properties.svg?style=flat-square)](https://www.npmjs.com/package/babel-plugin-react-remove-properties)
[![Build Status](https://travis-ci.org/oliviertassinari/babel-plugin-react-remove-properties.svg?branch=master)](https://travis-ci.org/oliviertassinari/babel-plugin-react-remove-properties)[![Dependencies](https://img.shields.io/david/oliviertassinari/babel-plugin-react-remove-properties.svg?style=flat-square)](https://david-dm.org/oliviertassinari/babel-plugin-react-remove-properties)
[![DevDependencies](https://img.shields.io/david/dev/oliviertassinari/babel-plugin-react-remove-properties.svg?style=flat-square)](https://david-dm.org/oliviertassinari/babel-plugin-react-remove-properties#info=devDependencies&view=list)## Installation
```sh
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**
```js
class Foo extends React.Component {
render() {
return (
Hello Wold!
);
}
}
```**Out**
```js
class Foo extends React.Component {
render() {
return (
Hello Wold!
);
}
}
```## 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
```sh
babel --plugins react-remove-properties script.js
```#### Via Node API
without options:
```js
require('babel-core').transform('code', {
plugins: [
'react-remove-properties',
],
});
```with options:
```js
require('babel-core').transform('code', {
plugins: [
['react-remove-properties', {properties: ['data-test', 'data-foo', /my-suffix-expression$/]}],
],
});
```## License
MIT