A
A
Anton Almost2016-04-08 11:29:46
Node.js
Anton Almost, 2016-04-08 11:29:46

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); 
   
});

Knowledgeable people please look at the code and tell me why it doesn’t update for me? If you remove Jade, then everything works ..

Answer the question

In order to leave comments, you need to log in

3 answer(s)
D
Danila, 2016-04-08
@Machinez

gulp.watch('app/*.html', browserSync.reload);
replaced by

gulp.watch('app/*.html').on('change', browserSync.reload);

L
Lenar Fattakhov, 2016-04-08
@fr_end

And why did you register sass in the task .pipe(browserSync.reload({stream: true})), but not jade in the task?

S
sergey, 2016-04-08
@zorro76

Here is the error, why did you put a semicolon after browser-sync

browserSync = require('browser-sync'); 
jade = require('gulp-jade');

It should be like this:
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 question

Ask a Question

731 491 924 answers to any question