So for the last while I've been working on making the edit-refresh cycle faster when one is working on the web part of a Cordova app. We can't do much about the native side, but there must be a faster way than saving the code, switching to Eclipse/Xcode, rebuilding and deploying.
There are two parts to the approach: Part 1: Refresh plugin This is launched at https://github.com/MobileChromeApps/refresh . It's a Javascript-only plugin that inserts an absolutely-positioned "refresh" button at the top-right corner of your app. Clicking it does a Javascript refresh of the page. This obviously doesn't work if you're loading the same files from the local device, so we need a server to point it at. Part 2: cordova serve I've added a new command to cordova-client, called cordova serve. This takes a platform and optional port (default 8000) and runs a simple node.js web server. Then you can point your app at your dev machine and test changes quickly. Example: cordova serve android cordova serve ios 9001 One interesting thing here is the "search paths". When you ask this server for a file, it looks first in your $PROJECT/www. If it finds the file, it responds with that. If it doesn't, it looks in the platform's www directory. This allows you to easily have platform-specific files: give them the same name and you'll magically get the right one at runtime. The new 0.1.13 version of cordova-client on npm has this code, so update your local copy with npm install -g cordova Problems: There are some pain points here that I'd like to address over the next few weeks, and want to see what the community thinks about them. 1. Most immediately, iOS doesn't support remote URLs, only files. This is being worked on by mmocny in time for 2.3.0. 2. Manually adding the <script> tags to include every new plugin is really lame. I propose a unified file, plugins.js or similar, that's always included in the index.html. Every time you add or remove a plugin, the Javascript files for all the plugins are concatenated into this file. There are likely some problems with this approach. Inserting/removing the <script> tags from the index page is also an option, though it requires more clever scripts. 3. Setting the start page manually on every platform sucks. I think this should be a value in config.xml that gets set on cordova build. Obviously that requires 1. to be fixed, but we'll get there soon. Any thoughts, suggestions, objections? Happy refreshing! Braden