Answer the question
In order to leave comments, you need to log in
Gulp+browsersync not updating html?
var gulp = require('gulp'),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
jade = require('gulp-jade');
gulp.task('sass', function(){
return gulp.src('app/sass/**/*.sass')
.pipe(sass())
.pipe(gulp.dest('app/css'))
.pipe(browserSync.reload({stream: true}))
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: 'app'
},
notify: false
});
});
gulp.task('jade', function(){
return gulp.src('app/jade/**/*.jade')
.pipe(jade())
.pipe(gulp.dest('app'))
});
gulp.task('watch', ['browser-sync', 'sass','jade'], function() {
gulp.watch('app/sass/**/*.sass', ['sass']);
gulp.watch('app/jade/**/*.jade', ['jade']);
gulp.watch('app/*.html', browserSync.reload);
});
Answer the question
In order to leave comments, you need to log in
gulp.watch('app/*.html', browserSync.reload);
replaced by
gulp.watch('app/*.html').on('change', browserSync.reload);
And why did you register sass in the task .pipe(browserSync.reload({stream: true}))
, but not jade in the task?
Here is the error, why did you put a semicolon after browser-sync
browserSync = require('browser-sync');
jade = require('gulp-jade');
var gulp = require('gulp'),
sass = require('gulp-sass'),
jade = require('gulp-jade'),
browserSync = require('browser-sync'),
reload = browserSync.reload;
gulp.task('sass', function() {
return gulp.src('app/sass/**/*.sass')
.pipe(sass())
.pipe(gulp.dest('app/css'))
.pipe(reload({
stream: true
}));
});
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: 'app'
},
notify: false
});
});
gulp.task('jade', function() {
return gulp.src('app/jade/**/*.jade')
.pipe(jade())
.pipe(gulp.dest('app'))
.pipe(reload({
stream: true
}));
});
gulp.task('watch', ['browser-sync', 'sass', 'jade'], function() {
gulp.watch('app/sass/**/*.sass', ['sass']);
gulp.watch('app/jade/**/*.jade', ['jade']);
gulp.watch('app/*.html', browserSync.reload);
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question