stample / gulp-browserify-react-phonegap-starter

A starter kit for Phonegap, using Gulp, Browserify and React
88 stars 7 forks source link

gulp-browserify-react-phonegap-starter

Inspired by the structure of Gulp-starter

This app uses at runtime:

At build time:

This creates a simple Gulp config that will build a simple app using Browserify and 2 React components. Here's a picture of it using Ripple emulator:

Picture

Only the very minimal files required are added to Git. The Cordova www folder for exemples is ignored and is only the result of a local build. During development, you only modify files in the src folder.

Using a Browserify trick, you can also express all your require calls with paths relative to the src folder. This means you don't have anymore to write require("../../../../../js/components/relativePathHellComponent") but you can simply write require("js/components/relativePathHellComponent") from any source file.

Versions

(Yes Cordova and Phonegap versions are not the same, I just show you versions that work on my computer but you should be able to use latest versions as well)

Install the tools

Update your bashrc:

export ANDROID_HOME=<YOUR_PATH>/adt-bundle-linux-x86_64-20140321/sdk
export PATH=$ANDROID_HOME/tools:$ANDROID_HOME/platform-tools:$PATH

START

gulp

This will create the appropriate Phonegap content in www based on your source files.

ripple emulate

Notice that if you want to do Ajax requests with Chrome, you have to disable the CORS securities in chrome and also disable the Cross Domain Proxy on Ripple settings.

Install Ant, ant command should be available. On Ubuntu: sudo apt-get install ant

Install AVD's with the android command (GUI)

Launch them with cordova emulate android

FAQ

Notice that if you want to do Ajax requests with Chrome in Ripple, you have to disable the CORS securities in chrome and also disable the Cross Domain Proxy on Ripple settings.

This happens because you didn't use the cordova platform add android command. Ripple needs the platform folder to be populated with some content, which is what this command do.

This is probably because Ripple is launched by default with an Android device selected. You can't use an Android device in Ripple unless you install the Android platform. But you can select an iOS device in Ripple and it should work this time.

More infos

Some useful links to read:

TODO