Gulp Watch - Gulp

What is Gulp Watch?

Watch method is generally used to monitor all your source files. If any changes are made to the source file then the watch will run an appropriate task. A ‘default’ task can be used to watch for the changes in HTML, CSS, and JavaScript files.

Update Default Task

In the preceding chapter, we have learnt how Gulp tasks can be combined using ‘default’ task. We can use gulp-minify-css, gulp-concatplugins, gulp-autoprefixer and created styles task to minify CSS files.

To have a look at the CSS file, we should update the ‘default’ task as shown in the below following code:

All the CSS files which are includes in work/src/styles/ folder will be watched and if any changes are made to the files, then styles task will get executed.

Run Default Task

We can run a ‘default’ task using the below command.

After the execution of the above command, we will receive the following output.

If any changes are done to CSS files, you will be receiving the following output.

Here,

gulp.run() has been deprecated. So we can use task dependencies or gulp.watch task trigger

ing instead.

Watch process will always remain active and respond to all the changes. Press Ctrl+C to CLOSE the monitoring process and return to the command line.

All rights reserved © 2020 Wisdom IT Services India Pvt. Ltd DMCA.com Protection Status

Gulp Topics