From 54f261e1b76bf68823a33330f1b9df9d544e9dbb Mon Sep 17 00:00:00 2001 From: Riku Rouvila Date: Wed, 12 Aug 2015 22:02:20 +0300 Subject: [PATCH] replace gulp's built-in watch with gulp-watch https://github.com/leonidas/gulp-project-template/issues/24 --- gulpfile.js | 10 +++++++--- package.json | 1 + 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 5e4c791..f5de596 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -19,6 +19,7 @@ var streamify = require('gulp-streamify'); var stylus = require('gulp-stylus'); var uglify = require('gulp-uglify'); var watchify = require('watchify'); +var watch = require('gulp-watch'); /*eslint "no-process-env":0 */ var production = process.env.NODE_ENV === 'production'; @@ -149,9 +150,12 @@ gulp.task('server', function() { }); gulp.task('watch', function() { - gulp.watch(config.templates.watch, ['templates']); - gulp.watch(config.styles.watch, ['styles']); - gulp.watch(config.assets.watch, ['assets']); + + ['templates', 'styles', 'assets'].forEach(function(watched) { + watch(config[watched].watch, function() { + gulp.start(watched); + }); + }); var bundle = watchify(browserify(browserifyConfig)); diff --git a/package.json b/package.json index bb7492f..f5068a5 100644 --- a/package.json +++ b/package.json @@ -34,6 +34,7 @@ "gulp-stylus": "~2.0.0", "gulp-uglify": "~1.0.1", "gulp-util": "~3.0.1", + "gulp-watch": "^4.3.4", "jsdom": "^5.6.0", "mocha": "^2.2.5", "node-notifier": "^4.2.1",