@kinka/babel-plugin-react-native-web

0.6.1 • Public • Published

babel-plugin-react-native-web

This is a forked version, will be removed once the feature(custom web module settings) merged to upstream

npm version PRs Welcome

A Babel plugin that will alias react-native to react-native-web and exclude any modules not required by your app (keeping bundle size down).

Installation

yarn add --dev babel-plugin-react-native-web

Usage

.babelrc

{
  "plugins": ["react-native-web"]
}

You can set your own web modules in babel options:

{
  "plugins": [
    ["react-native-web", {
      "Modal": "/your/path/to/Modal", "Text": "/your/path/to/Text"
    }]
  ]
}

Example

NOTE: react-native-web internal paths are not stable and you must not rely on them. Always use the Babel plugin to optimize your build. What follows is an example of the rewrite performed by the plugin.

Before

import { StyleSheet, View } from 'react-native';

After

import StyleSheet from 'react-native-web/dist/exports/StyleSheet';
import View from 'react-native-web/dist/exports/View';

Readme

Keywords

none

Package Sidebar

Install

npm i @kinka/babel-plugin-react-native-web

Weekly Downloads

0

Version

0.6.1

License

MIT

Unpacked Size

13.8 kB

Total Files

7

Last publish

Collaborators

  • kinka