gulp-watch
's direct dependencies. Data on all dependencies, including transitive ones, is available via CSV download.Name | Version | Size | License | Type | Vulnerabilities |
---|---|---|---|---|---|
ansi-colors | 1.1.0 | 4.35 kB | MIT | prod | |
anymatch | 1.3.2 | 3.31 kB | ISC | prod | 1 2 |
chokidar | 2.1.8 | 24.74 kB | MIT | prod | 8 |
fancy-log | 1.3.2 | 2.02 kB | MIT | prod | |
glob-parent | 3.1.0 | 2.78 kB | ISC | prod | 1 |
object-assign | 4.1.1 | 2.61 kB | MIT | prod | |
path-is-absolute | 1.0.1 | 1.84 kB | MIT | prod | |
plugin-error | 1.0.1 | 4.3 kB | MIT | prod | |
readable-stream | 2.3.8 | 25.14 kB | MIT | prod | |
slash | 1.0.0 | 1020 B | MIT | prod | |
vinyl-file | 2.0.0 | 2.14 kB | MIT | prod | |
vinyl | 2.2.1 | 7.4 kB | MIT | prod |
In the dynamic world of web development, 'gulp-watch' serves as an unending stream file watcher that makes use of the supremely speedy chokidar while emitting vinyl objects. It keeps a keen eye on files provided by a specific pattern or 'glob' and emits an event every time the file is added, changed, or removed.
To get things working with 'gulp-watch', you'll need to follow a few straightforward steps. First, install the package through npm by running npm install --save-dev gulp-watch
in your terminal. You'll then require both 'gulp' and 'gulp-watch' in your script file. Define gulp tasks that return the 'gulp-watch' function, providing it with the path of the files you want to watch as the first argument, and specifying a function of what to do whenever a change is detected.
Here's a simple code example:
var gulp = require('gulp'),
watch = require('gulp-watch');
gulp.task('stream', function () {
// Endless stream mode
return watch('css/**/*.css', { ignoreInitial: false })
.pipe(gulp.dest('build'));
});
gulp.task('callback', function () {
// Callback mode
return watch('css/**/*.css', function () {
gulp.src('css/**/*.css')
.pipe(gulp.dest('build'));
});
});
Notice there are two modes of utilization: 'stream' mode which creates an endless stream, and 'callback' mode that is particularly practical if any plugin in the pipeline depends on the end
/flush
event.