I have a problem that I thought could be common to many people, but it seems like I'm wrong. Therefore, I hope someone can help, since I cannot find the answer in the Gulp docs.
My gulpfile.js currently has the following content:
'use strict'; var gulp = require('gulp'); var jade = require('gulp-jade'); var gutil = require('gulp-util'); var stylus = require('gulp-stylus'); var jeet = require('jeet'); var nib = require('nib'); var uglify = require('gulp-uglify'); var livereload = require('gulp-livereload'); var sources = { jade: "jade/**/*.jade", partials: "partials/**/*.jade", stylus: "styl/**/*.styl", scripts: "js/**/*.js" }; // Define destinations object var destinations = { html: "dist/", css: "dist/css", js: "dist/js" }; // Compile and copy Jade gulp.task("jade", function(event) { return gulp.src(sources.jade) .pipe(jade({pretty: true})) .pipe(gulp.dest(destinations.html)) }); // Compile and copy Stylus gulp.task("stylus", function(event) { return gulp.src(sources.stylus).pipe(stylus({ use: [nib(), jeet()], import: [ 'nib', 'jeet' ], style: "compressed" })).pipe(gulp.dest(destinations.css)); }); // Minify and copy all JavaScript gulp.task('scripts', function() { gulp.src(sources.scripts) .pipe(uglify()) .pipe(gulp.dest(destinations.js)); }); // Server gulp.task('server', function () { var express = require('express'); var app = express(); app.use(require('connect-livereload')()); app.use(express.static(__dirname+'/dist/')); app.listen(4000, '0.0.0.0'); }); gulp.task('watch', function() { livereload.listen(); gulp.watch(sources.jade, ["jade"]); gulp.watch(sources.partials, ["jade"]); gulp.watch(sources.stylus, ["stylus"]); gulp.watch(sources.scripts, ["scripts"]); }); // Define default task gulp.task("default", ["jade", "stylus", "scripts", "server", "watch"], function(){ gulp.watch([ sources.jade, sources.partials, sources.stylus, sources.scripts, ]).on('change', function(event) { livereload.changed(); console.log('File', event.path, 'was', event.type); console.log('LiveReload is triggered'); }); });
What happens is that I have more than one jade file. When I work, say, in the 10th in alphabetical order, and I change it, I will immediately return to work with the furnace. The problem is that it reloads the browser tab before all the jade files finish compiling and copying to the destination, so the file that I am working on does not even compile when the update occurs. Is there any way to bind reboot after task completion?