Introducing Grunt

Our environment is set up; let's do something with it. We need something that will automatically run tasks. This is where Grunt comes in. We can give it a list of tasks that Grunt will execute. The first thing we need to do is create a Gruntfile.js file.

Building a basic Grunt file

Gruntfile.js configures Grunt. It tells Grunt what tasks to carry out, how to run each task, and in what order. We can now create a basic Gruntfile.js file in the root of the project. Add the following code snippet to the file:

module.exports = function(grunt) { grunt.initConfig({ pkg: grunt.file.readJSON('package.json') }); grunt.loadNpmTasks('grunt-contrib-uglify'); grunt.loadNpmTasks('grunt-contrib-concat'); grunt.loadNpmTasks('grunt-contrib-jshint'); ...

Get Building Scalable Apps with Redis and Node.js now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.