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...