10 Jan

PhoneGap + JavascriptMVC production build

Once you build your app and produce production.js and production.css (hopefully through an ant script like mine), you may notice that your app does not run once deployed with PhoneGap. This is because it seems the recommended way of bootstrapping your app in JMVC uses the script’s URI to specify the app name: “../steal/steal.production.js?myappname” which PhoneGap does not appear to support.

The simple workaround is to resort to this notation instead:

<script src="../steal/steal.production.js"></script>
<script>
    steal('myappname/production.js').then('myappname/myappname.js');
</script>

Now, your deployed assets will not contain myappname.js since you already built it into production.js. Once you load production.js you have essentially loaded all the javascript you told steal.build to package for you. Unfortunately, you need to remember that the build refers to your files from the perspective of the folder directly above your app, which means you need to load ‘myappname/myappname.js’ instead of ‘./myappname.js’.

These are minor issues and once you figure out the gotchas, it should be smooth sailing from there. I have divided my html into 2 files, one for development, and one for production. My Ant script now picks the right html to include as PhoneGap’s index.html depending on what I am building.

3 thoughts on “PhoneGap + JavascriptMVC production build

  1. Hey thanks for doing this — I’m very interested to see how your experiments come out. We use JMVC extensively and are considering mobile — and have been looking at Dojo for that. I’ll keep tuned in…
    Gary

  2. @GaryM I’ve heard some good things about Dojo for mobile dev. I chose jQuery because that’s what most of my engineers are familiar with, but the tricky bits should be the same as far as integration points. I also figured since I am paying the price of loading jQuery anyway to use JMVC, I might as well go full jQuery and use jQuery Mobile.

    What I haven’t fully compared are load speeds and responsiveness of jQuery Mobile vs Dojo. I haven’t seen any performance issues so far with jQm, but I’ll post them if I encounter any.

  3. When I’m trying to run the app (PhoneGap+jQM+JavaScriptMVC) at the iOS simulator, the app does not work. Is it required to host the files (eg. steal.js etc.) on a webhost?

    The app works perfect when using a local webserver on my macbook though.

Comments are closed.