console.log() statements to debug, test, and build code.
Ease of writing and maintaining build scripts
1 2 3 4 5 6 7 8 9 10 11 12 13 14
1 2 3 4 5 6 7 8 9 10 11
Node.js (using grunt)
1 2 3 4 5 6 7 8
Of all the above implementations, grunt wins for readability – it’s just a JSON object with an array of source files and a single destination file. The rake task is also straightforward, but it just wraps the command line and it requires UglifyJS to be installed globally before running it. As for the ant task… the XML speaks for itself.
The awesomeness of grunt + npm
We originally wrote our Node.js build script using jake, which is an npm package similar to Ruby’s rake. It worked… except we ended up with a 1000+ line build file to concatenate, minify, test, and deploy to Amazon S3.
In grunt, however, concatenation and minification tasks are built-in. It’s easy to load other grunt tasks via npm so you can develop custom grunt tasks that can be shared across projects (and the world!):
There’s a growing library of npm modules that define custom grunt tasks that will plug in to another grunt file. A search for “grunt” on search.npmjs.org returned 15+ modules that do everything from compile CSS to build CoffeeScript. There’s even an Amazon S3 module.
Grunt is straightforward to configure. If someone needs to make a build change, like adding a new build target, it’s as simple as modifying a centralized JSON configuration object. The grunt API also is well documented with many examples.