Exploring Grunt
Grunt is a Node.js module, which means it is installed via the Node.js package manager. To get started, we need to install Grunt's command-line tool.
npm install -g grunt-cli
The -g
flag sets the module as a global command so that we can run it in every directory. Once the installation finishes, we are able to run grunt
, which is executable. The instructions to the task runner are stored in the Gruntfile.js
file. Place this file in the root project's directory and place our tasks inside. Once we have filled the Grunt file, open the terminal, navigate to the directory, and type grunt
.
The Grunt's configuration file is like a rules list. Describe step by step what exactly needs to be done. The following code snippet is the simplest format of the Gruntfile.js
file:
module.exports = function(grunt) { grunt.initConfig({ concat:{ } }); grunt.registerTask('default', ['concat']); }
The tasks are set up in the object passed to the initConfig
function. In the preceding...