Install and set up Grunt

Grunt is the workhorse of the Node world. You need tasks run, then you put Grunt to work. If you are from the Rails world, Grunt is much like make or Rake. There is a TOM of documentation out there on this task runner, but in this workshop, I will focus on the basics that will get you up and running with an application.

Grunt is pretty simple to set up, create a new Gruntfile.js file in the root of your project and add the following shell syntax:

  1. module.exports = function(grunt) {
  2. grunt.initConfig({
  3. ...
  4. });
  5. grunt.loadNpmTasks('<package>');
  6. };

To run Grunt, it is typical to install Grunt globally:

  1. npm install grunt -g

BUT WAIT!! What about deployment? If we create tasks that require Grunt to run on the server, we need this to be a dependency on the app. So, let’s install this as a local dependency:

  1. npm install --save grunt

Using this base structure and Grunt installed, we can now begin to add new features to our app.