gulp - Gulp Watch - gulp sass - gulp tutorial - learn gulp
gulp tutorials tag - gulp , gulp sass , gulp watch , gulp meaning , gulp js , gulp uglify , concat javascript , eisi gulp , gulp concat , gulp install , gulp tutorial , what is gulp , npm install gulp , gulpjs
What is Gulp watch method?
- Gulp watch method is used to monitor source files.
- Any changes made into the source file, will trigger tasks specified into watch block.
Learn Gulp - Gulp tutorial - Gulp Watch - Gulp examples - Gulp programs
Installation
Example
- We are making change in the buildtask.
Watching Gulp Task
- It simply means, while executing build task, we are watching all the css files present in the src/styles folder. If any of the css file gets modified, gulp watch will capture that event and simply starts executing styles task.
- The Watch method is used to monitor your source files. When any changes to the source file is made, the watch will run an appropriate task.
- You can use the ‘default’ task to watch for changes to HTML, CSS, and JavaScript files.
gulp tutorials tag - gulp , gulp sass , gulp watch , gulp meaning , gulp js , gulp uglify , concat javascript , eisi gulp , gulp concat , gulp install , gulp tutorial , what is gulp , npm install gulp , gulpjs
Update Default Task
- We used gulp-minify-css, gulp-autoprefixer and gulp-concatplugins, and created styles task to minify CSS files.
- To watch CSS file, we want to update the ‘default’ task.
gulp tutorials tag - gulp , gulp sass , gulp watch , gulp meaning , gulp js , gulp uglify , concat javascript , eisi gulp , gulp concat , gulp install , gulp tutorial , what is gulp , npm install gulp , gulpjs
Sample Code
- All the CSS files under work/src/styles/ folder will be watched and upon changes made to these files, the styles task will be executed.
Run Default Task
- Run the ‘default’ task using the following command.
- After executing the above command, you will receive the following output.
- Whenever any changes are made to CSS files, you will receive the following output.
- The Watch process will remain active and respond to your changes. You can press Ctrl+C to terminate the monitoring process and return to the command line.
gulp tutorials tag - gulp , gulp sass , gulp watch , gulp meaning , gulp js , gulp uglify , concat javascript , eisi gulp , gulp concat , gulp install , gulp tutorial , what is gulp , npm install gulp , gulpjs
Usage
Tips and Note: Until gulpjs 4.0 is released, you can use gulp-plumber to prevent stops on errors.