HTML and CSS Reference
In-Depth Information
Minify files with UglifyJS
Run QUnit unit tests in a headless PhantomJS instance
Start a static web server
Run unit tests with nodeunit)
Run predefined tasks whenever watched files change
The following code is an example of a very basic sample grunt.js file that handles project
configuration, loading a grunt plug-in, and a default task:
module . exports =
function ( grunt ) {
// Project configuration.
grunt . initConfig ({
lint : {
all : [ 'grunt.js' , 'lib/**/*.js''test/**/*.js' ]
jshint : {
options : {
browser : true
// Load tasks from "grunt-sample" grunt plugin installed via Npm.
grunt . loadNpmTasks ( 'grunt-sample' );
// Default task.
grunt . registerTask ( 'default' , 'lint sample' );
You can easily set up a new grunt project by using the grunt init command. There are
a few different templates for various types of projects including CommonJS, jQuery, and
As an example, try running grunt on the slidfast.js library used in the previous chapters.
From the root of the project, in the terminal, run:
grunt init:gruntfile
This customizable template ( Figure 4-6 ) creates a single grunt.js file based on your an‐
swers to a few questions. Grunt also tries to determine source, unit test, and other system
paths using it's own environment detection.
Search WWH ::

Custom Search