O
O
OccamaRazor2016-10-11 15:24:27
gulp.js
OccamaRazor, 2016-10-11 15:24:27

How to tell gulp to watch all .html files in a given directory and update them with livereload?

Changed to '**/*.html' in 'watch' and 'html' , or both at once, but the expected result did not work. The 'html' task is executed, but the 'watch' task is not executed and the page is not reloaded after the changes made.

gulp.task('html',function(){
    gulp.src('*.html')
    .pipe(connect.reload());
})

gulp.task('watch', function() {
    gulp.watch('index.html',['html'])
});

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sergey, 2016-10-11
@zorro76

Well, like this for example:

var src = {
        html: ['./src/*.html']
},

gulp.task('html', function() {
    gulp.src(src.html)
        .pipe(connect.reload())
});

gulp.task('watch', function() {
   gulp.watch('./src/**/*.html', ['html']);
});

working example

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question