Setting up a Cordova build environment with some Grunt
Using the task-based build tool
Grunt
, the new
Cordova
command line tooling,
and
Jasmine
tests running in
PhantomJS
to build better apps
Why?
- Build automation
- Continuous integration (Travis-CI, etc)
- Test/behaviour driven development
- Xcode, Eclipse and friends are painful
- Multiple platforms, one code base
- The command line is powerful
- There are many great
Grunt plugins
Just 9 easy* steps!
- Install the 4 primary dependencies
- Create a Cordova project
- Add your Cordova platforms (iOS, Android, etc)
- Create a
package.json
file
- Install the 3 grunt plugin npm modules using --save-deps
- Initialise Grunt and create a
grunt.js
file
- Hand edit the
grunt.js
file and edit your src paths
- Hand edit the
grunt.js
file and add your Jasmine tasks
- Hand edit the
grunt.js
file and add your Cordova shell tasks
* Easy is a relative term... are you scared of hand editing config files? Hope not.
The steps were so complex I didn't even want to write them up
:*(
Much less try to describe it in a talk...
Luckily, you can write custom Grunt scaffolding templates...
...or even better get someone else to write it for you:
Now it's just 6 actually easy steps*
-
Install the 4 primary dependencies
- Install the grunt-init-cordova templates
- Create a Cordova project
- Add your Cordova platforms (iOS, Android, etc)
-
Initialise Grunt with the templates above (answering a couple of easy questions)
- Run
npm install
to install all dependencies
THAT'S IT! WE ARE READY TO ROLL!
* The first step still sucks...
Optional
Next steps
- Pick a UI framework
- Decide on a MVC framework
- Choose or build a backend
- Actually build your app!
Thanks
Feel free to ask me any PhoneGap / Cordova questions you may have as long as they have nothing to do with jQuery Mobile.
Just kidding. *
* I'm totally not kidding.