yeoman/yeoman — pull request #709 by cobbweb (2012-11-12 05:43:22+00:00)
Title: Make server and build tasks configurable from Gruntfile.js

Try reading custom configuration from the project's Gruntfile.js, falling back to Yeoman's default tasks.

This is expanding on @jgrund's pull request (https://github.com/yeoman/yeoman/pull/669) but I thought we should nest the tasks configuration so the targets don't conflict with possible future configuration.

I also added _beforeAll and _afterAll which I really need on the build task. I added this to the server task too, just to keep it consistent.

I had a quick crack at writing tests for this but couldn't get them working, but I'm using this in my project without troubles and this shouldn't break backward compatibility. If someone wants to point me in the right direction for tests I'd be happy to try again when I've got a chance.

E.g.

```javascript
module.exports = function( grunt ) {
'use strict';

grunt.loadNpmTasks('grunt-contrib-handlebars');
grunt.loadNpmTasks('grunt-recess');

//
// Grunt configuration:
//
// https://github.com/cowboy/grunt/blob/master/docs/getting_started.md
//
grunt.initConfig({

// ... handlebars and recess config here ...

server: {
tasks: {
app: 'clean recess handlebars open-browser watch',
_afterAll: 'mytask'
}
},

build: {
tasks: {
_beforeAll: 'clean recess handlebars mkdirs'
}
}

// ... more grunt config ...

});

});
```