How to package react-native application

2.7k Views Asked by At

I am building a sample react native application. Currently i am running it using the node server.Node server is serving the js file. You can see this in following screenshot:

enter image description here

I want to shift to the option2, for this, if there is any change in the js file, i need to run the curl command manually.

Is there any alternative for this?

2

There are 2 best solutions below

0
On

AFAIK there's nothing in place and this is work in progress. See:

https://github.com/facebook/react-native/issues/12

We plan on putting in some sort of build step that "compiles" the JS source directly into a resource file in the app bundle. Obviously in production you wouldn't have a server running nearby.

There's another bit of discussion here.

At the moment I think you're stuck with the curl option.

0
On

All this does is packing all your JavaScript together and writing it into a single file. Option 1 has a small http server running, providing the latest packed file when you request it. Option 2 takes the file from the local disk.

You can setup a tool that looks watches your project files and repacks everything if you make changes.

You can do this by yourself, using the packaging tool shipped with react-native (react-native bundle [--minify]) and re-run it everytime things changes using gulp (and gulp-watch).

Also you can use webpack as your packaging tool and use the --watch option. (see example)