babel-plugin-react-native

2.0.0 • Public • Published

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" }]]
}

Dependents (1)

Package Sidebar

Install

npm i babel-plugin-react-native

Weekly Downloads

10

Version

2.0.0

License

ISC

Unpacked Size

12.4 kB

Total Files

13

Last publish

Collaborators

  • churpeau