Shaun Dunne: Grunt your Way to Glory
Shaun Dunne (@shaundunne) was speaking at Side View about Grunt, these are my notes from his talk.
Automation isn't being lazy, it's being efficient. Web dev has a lot of tasks that form part of our workflow and we don't have to do them manually - there are task runners.
Grunt runs everywhere that node runs - which is pretty much everywhere.
package.json
- this is the config file for the plugins and all it's dependencies. You don't have to put all the decepdencies in version control, the package file takes care of this. grunt-contrib-*
plugins are maintained by the core team.
Gruntfile.js
defines the tasks we want to do. We load in the plugins and have a config object for these plugins. We also define tasks that carry out tasks. Has a templating system so we can use variables such as date. Has really good globbing for filesystem matching e.g. assets/**/*.js
, !**/*.min.js
.
Everything about grunt is a plugin. As we're in node we can use matchdep
to to load modules rather than manually loading packages.
Used by lots of projects - jQuery, WordPress, Yeoman, JSBin, ghost. Over 50,000 GitHub projects are using it. There are ~1,500 plugins for Grunt. There are compilers for all the major pre-processors.
Plugins to check out:
- grunt-embed
- grunt-assemble
- grunt-contrib-watch
- grunt-responsive-images
- grunt-mocha
- grunt-casper
- grunt-breakshots
- grunt-init
Grunt is basically a big config file but it's also just JavaScript - you can write functions to perform operations. It's consistent, plugins have a mostly common syntax which makes it easier to switch. Excellent community as evidenced by the plugins.
Use it, learn to love automation, look at other project's Gruntfiles (they are the best documentation), contribute.