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)

Creating a Grunt plugin


We will be using grunt-init, which is a scaffolding tool.

Using the Grunt plugin scaffold

Grunt provides you with a plugin module creation with grunt-init-gruntplugin, which will scaffold your plugin authoring environment. While using gruntplugin is not mandatory, it is recommended by the Grunt team. The gruntplugin requires grunt-init to be installed. Clone grunt-init-gruntplugin from its repository:

git clone git://github.com/gruntjs/grunt-init-gruntplugin.git ~/.grunt-init/gruntplugin.

In Windows, the destination path should be modified to %USERPROFILE%\.grunt-init\gruntplugin.

Alternatively, navigate to https://github.com/gruntjs/grunt-init-gruntplugin, where you can download the plugin files, and then place the template in your ~/.grunt-init directory. Once the template has been added, run the following from the directory where you wish to author your plugin:

cd path/to/plugin_directory
grunt-init gruntplugin

The output is as follows:

Following the illustration of...