That’s what Grunt aims to be. It has a bunch of built-in tasks that will get you pretty far, with the ability to build your own plugins and scripts that extend the basic functionality.
Just install it with
npm install -g grunt
and see for yourself.
watch in action
As of now, grunt has the following predefined tasks that you can use in your project:
- concat - Concatenate files.
- init - Generate project scaffolding from a predefined template.
- lint - Validate files with JSHint.
- min - Minify files with UglifyJS.
- qunit - Run QUnit unit tests in a headless PhantomJS instance.
- server - Start a static web server.
- test - Run unit tests with nodeunit.
- watch - Run predefined tasks whenever watched files change.
In addition to the built-in tasks, we can always create our own tasks. Don’t like a built-in task’s default behavior? Override it. Check out the grunt API documentation and the built-in tasks source for everything you need to know about creating custom tasks.
Also, creating a grunt plugin allows you to package related tasks into an easily-installed npm module. Backbone Boilerplate is a good example of a grunt plugin.
Initializing a new project
The init task initializes a new project, based on the current environment and the answers to a few questions. Once complete, a grunt.js configuration file will be generated along with a complete directory structure, including a basic readme, license, package.json, sample source files and unit tests (etc). The exact files and contents created depend on the template chosen along with the answers to the questions asked.
Now, instead of sketching out an idea in a quick one-off gist, We can create the scaffolding for an entire project in about 10 seconds, “fill in the blanks,” and then run grunt to lint, test, concat and minify my code. If everything passes, we can then commit and push code.