i need help with my gulp tasks.
After compiling index.html from PUG, Gulp watch task don't refresh browser.
This is my watch.js
var gulp = require('gulp'),
watch = require('gulp-watch'),
browserSync = require('browser-sync').create();
gulp.task('watch', function(){
browserSync.init({
notify: false,
server: {
baseDir: "app"
}
});
watch('./app/index.html', function(){
browserSync.reload();
});
watch('./app/assets/pug/*.pug', function(){
gulp.start('htmlRefresh');
});
});
gulp.task('htmlRefresh', ['pug'] ,function(){
browserSync.reload();
});
this is my pug.js
var gulp = require('gulp'),
pug = require('gulp-pug'),
notify = require('gulp-notify');
gulp.task('pug',function(){
return gulp.src('./app/assets/pug/*.pug')
.pipe(pug({ pretty: true }))
.on('error', notify.onError(function (error) {
return {
title: 'Pug',
message: error.message
}
}))
.pipe(gulp.dest('./app'));
});
On the output I get compiled HTML code in folder './app/index.html'. Watch task must reload browser:
watch('./app/index.html', function(){
browserSync.reload();
});
But nothing changes. Where is the mistake?
"browser-sync" only works there is tag "body". When I test this Gulp tasks, I experimented with single html tag, without .