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

Adding the Less compiler task


The Less task is the core task that you will need for your Less development. It has several features and options but at the heart of it is the Less compiler that can compile your Less files to CSS. By the end of this recipe, you will have a good understanding of this plugin, how to add it to your Gruntfile.js file, and how to take advantage of it.

Getting ready

The only requirement for this recipe is to have the Less plugin installed and loaded in your Gruntfile.js file. If you have not installed this plugin in the Installing Grunt plugins recipe of this chapter, you can do this using the following command in the root of your project:

$ npm install grunt-contrib-less --save-dev

How to do it…

The simplest form of the Less task configuration is shown in the following code. Start by adding it to your Gruntfile.js file after app: {dev: 'app/dev'},:

less: {
  dev: {
    files: {
      "app/dev/css/app.css": "app/dev/less/app.less"
    }
  }
}

Now, your Gruntfile.js file...