babel-plugin-react-native

<h3 align="center"> babel-plugin-react-native </h3>

Downloads in past

Stats

StarsIssuesVersionUpdatedCreatedSize
babel-plugin-react-native
131.0.1a year agoa year agoMinified + gzip package size for babel-plugin-react-native in KB

Readme

babel-plugin-react-native


Features

This plugin was created to allow tree-shaking when building for multiple react-native platforms.

Install

npm install --save-dev --save-exact babel-plugin-react-native

Example

Source:
import { Platform } from 'react-native';

if (Platform.OS === 'web') {
  console.log('web');
} else {
  console.log('not web');
}

Transformed to (with OS: "web"):
if ('web' === 'web') {
  console.log('web');
} else {
  console.log('not web');
}

Usage

Via babel.config.json

{
  "plugins": [["babel-plugin-react-native", { "OS": "web" }]]
}