There may be a better way to do what you want to do.
Have you thought about maybe using an instance of express
with livereload
?
The alternative is to use gulp-connect
which will make what you're trying to do much easier. In either case, instead of invoking livereload
within tasks, handle livereloading within the task that sets up your server. The general idea is that you set a watch task on your files that you want livereloading and then reload on changes.
gulp.task('serve', function(event) {
connect.server({
root: destinations.docs,
port: 1987,
livereload: true
});
// sets up a livereload that watches for any changes in the root
watch({glob: [sources.html, sources.styles]})
.pipe(connect.reload());
});
I've experimented with both ways and gulp-connect
is a much easier option. Regardless, I've written two gulp boilerplates which you can see at https://github.com/jh3y/gulp-boilerplate-v2 and https://github.com/jh3y/gulp-boilerplate .
Hope that helps!