| 1. |
What Is Gulp.watch And How To Use It? |
|
Answer» As we write code and MODIFY your files, the gulp.WATCH() method will watch for changes and automatically RUN our tasks again so we don’t have to run the gulp command each time. 1 gulp.watch(GLOB [, opts], tasks) or gulp.watch(glob [, opts, cb]) ? Example:
Here we have defined a task named “watch”, in which we are watching for js files changes and CSS files changes using gulp.watch. And whenever, there is any change in .js file, then run [scripts] task (which should be already defined in your gulpfile.js) and in case of .scss file changes, run [sass] task. As we write code and modify your files, the gulp.watch() method will watch for changes and automatically run our tasks again so we don’t have to run the gulp command each time. 1 gulp.watch(glob [, opts], tasks) or gulp.watch(glob [, opts, cb]) ? Example: Here we have defined a task named “watch”, in which we are watching for js files changes and css files changes using gulp.watch. And whenever, there is any change in .js file, then run [scripts] task (which should be already defined in your gulpfile.js) and in case of .scss file changes, run [sass] task. |
|