Book Image

Less Web Development Cookbook

Book Image

Less Web Development Cookbook

Overview of this book

Table of Contents (19 chapters)
Less Web Development Cookbook
Credits
Foreword
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Loading Grunt tasks


Instead of loading all the required Grunt plugins one by one, you can load them automatically with the load-grunt-tasks plugin.

Getting ready

For this recipe, you need to install the load-grunt-tasks plugin. You can install this by using the following command in the root of your project:

$ npm install load-grunt-tasks --save-dev

How to do it…

Add the following line at the very beginning of your Gruntfile.js file after module.exports:

require('load-grunt-tasks')(grunt);

Now your Gruntfile.js file should look like this:

module.exports = function(grunt) {
     require('load-grunt-tasks')(grunt);
     grunt.initConfig({
            pkg: grunt.file.readJSON('package.json'),
            app: {
                    dev: 'app/dev'
            },
    //Add the Tasks configurations here.
  });
    // Define Tasks here
};

How it works...

The load-grunt-tasks plugin loads all the plugins specified in the package.json file. It simply loads the plugins that begin with the grunt- prefix or any...