babel-plugin-transform-react-native-style-optimizer
Optimize inline style attributes in react-native. Removes duplicate style definitions and moves styles to a StyleSheet.
Example
In
<View style= width: 100 height: 100 />;<View style= width: 100 height: 200 height: 100 width: 100 width: 100 height: 200 width: 100 height: 100 />;
Out
<View style=_styless0 />;<View style=_styless1 _styless0 />; const _styles = StyleSheet;
Installation
npm install --save-dev babel-plugin-transform-react-native-style-optimizer
Usage
.babelrc
(Recommended)
Via .babelrc
Via CLI
babel --plugins transform-react-native-style-optimizer script.js
Via Node API
;