Skip to content

eval-printer/react-native-webpack-starter-kit

 
 

Repository files navigation

react-native-webpack-starter-kit

Build Status Dependency Status devDependency Status Gitter

A forward-looking approach to building with React Native.

React Native Webpack Starter Kit

Takes a minimalistic lean on tooling. Follows the latest React Native stable release. Uses Babel 6 for ES6-style JSX transpilation with ES7 Stage 1 support, and Webpack as a dev server and module bundler. Provides static code linting using ESLint and build output in the same console window, and Source Maps for debugging in the browser.

Leverages react-native-webpack-server. Incorporates sane default linting rules. Uses Greenkeeper to help keep dependencies fresh. Unprescriptive in terms of test frameworks and Flux implementations. Use with EditorConfig to help code consistency between editors. Try with webpack-notifier for desktop notifications on OS X.

For an example implementation take a look at Lumpen Radio. Or check out a few other Awesome React Boilerplates.

Requirements

Stack

Installation

OS X users start by cloning this repo and installing dependencies once your environment is set-up:

git clone https://github.com/jhabdas/react-native-webpack-starter-kit.git native-starter-kit && cd $_
npm i

The official React Native Getting Started documentation suggests OS X is required for development. However, I've created a custom virual environment for Windows users to get in on the fun too. See Using with Docker section for setup instructions.

Running

Once dependencies are installed, run the starter kit with:

npm start

This will start the React Packager and a Webpack Dev Server. The dev server will watch your JS files for changes and automatically lint and generate the index.[platform].js files expected by your React Native iOS or Android app.

iOS

Open ios/App.xcodeproj in Xcode, build and run the project.

Unlike the app currently generated by react-native init this app removes the UIViewControllerBasedStatusBarAppearance key to prevent the app from logging an error in Xcode and leading to an App Store rejection. The key may be added back, if desired, but its value must be set to true to prevent unexpected rejection during the review process.

Android

For android development use the following:

npm run android-setup-port # Note that this option is available on devices running android 5.0+ (API 21)
react-native run-android

Note Android support in React Native is relatively new, so expect some hiccups. Please see the official Android Setup documentation for getting set-up and the README in RNWS for additional information. And here's some helpful npm scripts courtesy of @niftylettuce.

If you run into any issues please see the Getting Started guide for React Native before submitting an issue.

Testing

As a minimalist seed this project does not introduce a testing framework. Instead it leverages simple static code analysis to help prevent coding mistakes and introduce some good practices for building React Native apps with ES6 and ES7.

Webpack is configured with a pre-loader to lint the application with ESLint using the Babel parser during app development. And the npm test command may be run at anytime to lint source code otherwise. See the .eslintrc file to adjust linter rules to your liking.

Bundling

Building the app for distribution.

  1. Execute npm run bundle to generate the offline JS bundle.
  2. For iOS, update AppDelegate.m to load from pre-bundled file on disk.
  3. Test the application, create an archive and submit to the store.

Submitting to Store

Please see Submitting to App Store for instructions on iOS. If you have any good Android instructions, please send a PR this way. Good luck and have fun out there!

Using with Docker

Windows users may experience problems with React Native development. This kit includes a Dockerfile which can be used to create a virtualized development environment for building your app on a Windows machine. To use it set-up Docker Machine then run the following commands with cmder (or similar) to get going:

  1. Clone this repo then update .watchmanconfig to the following: {"ignore_dirs": ["node_modules"]}.
  2. Run docker build --rm . command from the project root directory to build a virtualized Linunx environment configured for development using this starter kit.
  3. Get the ID of the built Docker image by running docker images and looking for the most recently created image.
  4. Then shell into the box with docker run -it 09608e4ec865 /bin/bash (where 09608e4ec865 is the Image ID) and run the app with npm start.

Support should be considered experimental, though I'm planning to develop a workflow allowing development on CoreOS running on a Raspberry Pi.

If iOS and Android device emulators are not available for your development environment (anything except OS X, basically) consider shipping code directly to a native device using Exponent.

About

🌿 Write your React Native app using future JavaScript and decoupled build tools.

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Objective-C 56.1%
  • JavaScript 32.8%
  • Java 11.1%