Answer the question
In order to leave comments, you need to log in
BrowserSync + gulp only reloads the page once, what's the problem?
There is such a piece of code in the gulpfile.js file
gulp.task('jade', function(){
return gulp.src('app/jade/*.jade')
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest('app'));
});
gulp.task('jade-watch', ['jade'], browserSync.reload);
gulp.task('default', ['jade'], function() {
browserSync.init({
notify: false,
server: {
baseDir: ['.tmp','app']
}
});
gulp.watch(path.jade, ['jade-watch']);
});
[BS] Serving files from: .tmp
[BS] Serving files from: app
[19:49:22] Starting 'jade'...
[19:49:23] Finished 'jade' after 492 ms
[19:49:23] Starting 'jade-watch'...
[BS] Reloading Browsers...
[19:49:29] Starting 'jade'...
[19:49:29] Finished 'jade' after 421 ms
[19:49:46] Starting 'jade'...
[19:49:46] Finished 'jade' after 382 ms
var browserSync = require('browser-sync').create()
var jade = require('gulp-jade');
var path = {
jade: 'app/jade/**/*.jade',
};
gulp.task('jade', function(){
return gulp.src('app/jade/*.jade')
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest('app'));
});
gulp.task('jade-watch', ['jade'], browserSync.reload);
gulp.task('default', ['jade'], function() {
browserSync.init({
notify: false,
server: {
baseDir: ['.tmp','app']
}
});
gulp.watch(path.jade, ['jade-watch']);
});
gulp.task('jade-watch', ['jade'], function(){
browserSync.reload();
});
Answer the question
In order to leave comments, you need to log in
gulp.task('jade-watch', ['jade'], browserSync.reload);
gulp.task('jade', function(){
return gulp.src('app/jade/*.jade')
.pipe(jade({
pretty: true
}))
.pipe(gulp.dest('app'));
});
gulp.task('watch', function() {
gulp.watch(path.html).on('change', browserSync.reload);
gulp.watch(path.jade, ['jade']);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question