Questions tagged [gulp-watch]

A gulp plugin that listens for file changes and emits changed files into the stream. Not to be confused with the built-in gulp.watch().

Installation

npm install --save-dev gulp-watch

Usage

gulp.task('watch-css', function () {
  return gulp.src('css/**/*.css')
    .pipe(watch('css/**/*.css'))
    .pipe(gulp.dest('build'));
});

Recipes

Links

827 questions
126
votes
12 answers

Everytime I run gulp anything, I get a assertion error. - Task function must be specified

I'm trying to run the command below but unfortunately I run into errors. $ gulp build In my terminal and I get this assertion error. I've uninstalled node and NPM and reinstalled again using brew - How do I completely uninstall Node.js, and…
Arthur Truong
  • 1,454
  • 3
  • 5
  • 13
73
votes
6 answers

How to Gulp-Watch Multiple files?

I have something like this: gulp.task('default', ['css', 'browser-sync'] , function() { gulp.watch(['sass/**/*.scss', 'layouts/*.css'], function() { gulp.run('css'); }); }); but it does not work, because it watches two…
LoveAndHappiness
  • 8,485
  • 19
  • 65
  • 101
66
votes
14 answers

How can Gulp be restarted upon each Gulpfile change?

I am developing a Gulpfile. Can it be made to restart as soon as it changes? I am developing it in CoffeeScript. Can Gulp watch Gulpfile.coffee in order to restart when changes are saved?
coool
  • 7,725
  • 12
  • 50
  • 77
63
votes
2 answers

Gulp - copy and rename a file

I'm extremely new to Gulp. I'm basically trying to watch for a modified JavaScript file, and then make a new copy of it with a new name. (eventually there'll be some processing on it, but Rome wasn't built in a day). My (naive) attempt is…
Adam Rackis
  • 79,454
  • 49
  • 255
  • 377
59
votes
9 answers

How to run a task ONLY on modified file with Gulp watch

I have the current gulp task which I use in a gulpfile. Path are from a config.json and everything works perfectly: //Some more code and vars... gulp.task('watch', function() { gulp.watch([config.path.devfolder+"/**/*.png",…
soenguy
  • 1,264
  • 2
  • 11
  • 21
50
votes
11 answers

How do I install gulp 4

I've been using gulp-watch. The current version of gulp-watch relies on the call gulp.parrallel. This call is only available from gulp 4. However gulp 4 is not available via the npm repo. npm info gulp dist-tags returns: { latest: '3.9.0' }. I can…
dave dave
  • 857
  • 3
  • 10
  • 15
46
votes
3 answers

Gulp TypeError: Arguments to path.join must be strings

I have i problem with gulp-ruby-sass. When i try to run the watch task and change some .sass files it occurs error: TypeError: Arguments to path.join must be strings Here is my gulpfile.js var gulp = require('gulp'); var jade =…
Andrew Gnilitskiy
  • 462
  • 1
  • 4
  • 8
30
votes
5 answers

Gulp Watch only run once

I'm using this Gulp Watch sample: https://github.com/floatdrop/gulp-watch/blob/master/docs/readme.md#starting-tasks-on-events. var gulp = require('gulp'); var watch = require('gulp-watch'); var batch = require('gulp-batch'); gulp.task('build',…
dhrm
  • 13,469
  • 29
  • 102
  • 163
29
votes
3 answers

CSS minify and rename with gulp

I've a variable like var files = { 'foo.css': 'foo.min.css', 'bar.css': 'bar.min.css', }; What I want the gulp to do for me is to minify the files and then rename for me. But the tasks is currently written as (for one…
Howard
  • 17,155
  • 33
  • 104
  • 173
22
votes
4 answers

Running existing task with gulp-watch

I've got some tasks already defined in gulpfile.js and I want to use gulp-watch plugin (to run tasks on new files). My question is, because I couldn't find anything, can I run my existing tasks while running watch (from plugin) function? var gulp =…
Tomasz Kasperek
  • 1,047
  • 3
  • 11
  • 30
19
votes
1 answer

Can I install just Gulp globally?

I'm constantly working on new web development projects that don't ever, in practice, need their node_modules folder when deploying. It would suit me much more if I was just able to create a small gulpfile.js for each project, rather than 6000+ files…
Chuck Le Butt
  • 43,669
  • 58
  • 179
  • 268
19
votes
2 answers

How to pipe to another task in Gulp?

I try to DRY my gulpfile. There I have small duplication of code I not comfortable with. How can this be made better? gulp.task('scripts', function() { return gulp.src('src/scripts/**/*.coffee') .pipe(coffeelint()) …
srigi
  • 1,497
  • 1
  • 14
  • 29
16
votes
3 answers

Set a Gulp task to be the default

I have the following task in my gulpFile, created by someone else on my team: gulp.task('serve', [], function(){ gulp.run( 'fonts', 'browsersync', 'watch' ); }); I would like to leave it alone, but I also wanted to map the default…
Steve
  • 12,696
  • 26
  • 104
  • 191
15
votes
2 answers

Get Gulp watch to perform function only on changed file

I am new to Gulp and have the following Gulpfile var gulp = require('gulp'); var jshint = require('gulp-jshint'); var concat = require('gulp-concat'); var rename = require('gulp-rename'); var uglify = require('gulp-uglify'); gulp.task('compress',…
bmdeveloper
  • 181
  • 1
  • 1
  • 8
15
votes
1 answer

Pausing file watchers until git checkout complete

What does git do when starting the checkout operation? Does it write out a lock file or something? I use gulp, and I'd like it to "pause" the watchers if git is actively performing a checkout operation. I'm okay with possibly having to "resave"…
enorl76
  • 2,298
  • 19
  • 33
1
2 3
55 56