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

836 questions
179
votes
13 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
  • 2,044
  • 3
  • 9
  • 15
76
votes
7 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
  • 9,735
  • 21
  • 72
  • 106
67
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
  • 8,085
  • 12
  • 60
  • 80
66
votes
3 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
  • 82,527
  • 56
  • 270
  • 393
60
votes
10 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,332
  • 3
  • 11
  • 23
52
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
  • 947
  • 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
31
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
  • 14,335
  • 34
  • 117
  • 183
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
  • 19,215
  • 35
  • 112
  • 184
24
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,147
  • 3
  • 13
  • 35
20
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
  • 47,570
  • 62
  • 203
  • 289
20
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,682
  • 1
  • 15
  • 30
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
  • 14,401
  • 35
  • 125
  • 230
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,562
  • 1
  • 25
  • 38
1
2 3
55 56