Answer the question
In order to leave comments, you need to log in
How to refresh Gulp browser on html change?
I want to make a task for Galp that will refresh browser-sync running from the public folder when I change index.html in the source folder .
My gulpfile.js is like this:
gulp.task('build', function() {
gulp.src('source/index.html')
.pipe(gulp.dest('public/'))
.pipe(reload({stream: true}))
})
gulp.task('server', function() {
browserSync.init({
server: {
baseDir: "public/"
}
})
})
Answer the question
In order to leave comments, you need to log in
gulp.task('default', ['server'], function(){
gulp.watch(['путь к файлам html'], browserSync.reload());
});
Ok, I put it together myself:
gulp.task('buildHTML', function() {
gulp.src('source/index.html')
.pipe(gulp.dest('public/'))
.pipe(reload({stream: true}))
})
gulp.task('watch', function() {
gulp.watch('source/scss/*.scss', ['compileSass'])
gulp.watch('source/index.html', ['buildHTML'])
})
gulp.task('server', function() {
browserSync.init({
server: {
baseDir: "public/"
}
})
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question