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 watch task


In this recipe, you will add the watch plugin. This plugin enables you to watch files and folders for any changes and execute certain tasks upon any change. In this recipe, you will add the watch task to watch for changes in the development folder and trigger the Less task every time any of the Less files is changed.

Getting ready

The only requirement for this recipe is to have the watch 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-watch --save-dev

How to do it…

In order to add the watch configuration, add the following lines to your Gruntfile.js file after the Less task configuration:

watch: {
     dev: {
            options: {
                   livereload: true
            },
            files: ['<%=app.dev%>/**', '!<%= app.dev %>/css/**'],
            tasks...