Book Image

Learning Grunt

By : Douglas Reynolds
Book Image

Learning Grunt

By: Douglas Reynolds

Overview of this book

With the increasing focus on task automation, the Grunt task runner is a vast platform that allows you to incorporate automation into your workflows. At the outset, you will learn how to use Node.js and NMP through an example. You will then find out how to build a sample app and the development environment for it. You will further delve into the implementation of Grunt plugins and the configuration of Grunt tasks. Furthermore, you will explore the various methods and packages for workflow automation. The final chapter will cover some advanced concepts, such as configuration variables and how to create a Grunt plugin. By the end of the book, you will have gained the fundamentals of Grunt and progressed through advanced concepts, including building a Grunt plugin.
Table of Contents (15 chapters)

Gruntfile.js configuration


This is one way to create Gruntfile.js; alternatively, we can copy and paste the sample Gruntfile from http://gruntjs.com/sample-gruntfile or we can start from scratch. We will begin from scratch so that the process of creating Gruntfile.js can be reviewed and discussed as we apply the configuration in the context of sample_project. When completed, we will have a configuration file that is ready to be used to build our project, which we will discuss in the next chapter.

When starting from scratch, first create an empty file in the root of sample_project named Gruntfile.js. Your project tree should look like the following:

We start with creating the wrapper, which—as discussed—is required in order to inject the Grunt object into the configuration. This is accomplished by the Grunt argument in the anonymous function that is assigned to module.exports. The module.exports function allows the Grunt configuration to be required as a module by Grunt. This allows the module...