Colin Gemmell: Automating with Grunt.js

Orde Saunders' avatarPublished: by Orde Saunders

Colin Gemmell (@colin_gemmell) was talking about using automating with grunt.js at Scotland.js, these are my notes from his talk.

Good developers should be extremely lazy - get bored doing something more than once.


JavaScript build script runs on Node.js - any code you can write with node you can run in grunt: 760 plugins already! Installed via npm. Core and CLI are two separate components.

Yeoman is a scaffolding tool that runs on top of grunt to build out a project template.

Configured by Gruntfile.js. This is plain JS. Define tasks in the file and load plugins using NPM. Getting JSHit is four lines of JS. Contrib package can install dependencies - such as phantom.js. Tasks can be combined into single tasks to run them together.

Two watch plugins:

  • watch - default grunt watch plugin.
  • regarde - sends notification of file(s) changed so can only run relevant tasks.

Live reload can be used to automatically reload the browser once the tasks have run. This can effectively make your IDE a live editor in the browser.

Can use plugins to upload to S3 for deployment. Concatenate, minify and build can all be run prior to deployments.

Use a package.json file to describe dependencies. Can hook this into grunt to avoid duplicating this information.

When a task fails grunt stops so you can get deployment only when all tasks succeed.

Comments, suggestions, corrections? Contact me via this website