D
D
Dmitry Sergeevich2015-10-19 11:39:47
gulp.js
Dmitry Sergeevich, 2015-10-19 11:39:47

How to compile JADE and SASS synchronously via gulp-watch?

Hello everyone, I'm having trouble compiling jade using gulp-watch . If there is an error in writing a jade file, the jade compilation task crashes and starts working only after the task is reloaded.
Can anyone help with writing a task using gulp-watch , which I don’t have any. Jade crashes and that's it.
Currently jade and sass compiles like this (and it works, but it's ugly, I want it with gulp-watch ):

gulp.task('jade', function () {
    return gulp.src('./dev/jade/*.jade')
      .pipe(plumber({errorHandler: notify.onError("(•): <%= error.message %>")}))
      .pipe(jade({pretty: true}))
      .pipe(gulp.dest('./'));
  });

gulp.task('sass', function () {
    return gulp.src(main_css)
      .pipe(plumber({errorHandler: notify.onError("(•): <%= error.message %>")}))
      .pipe(sourcemaps.init())
      .pipe(sass())
      .pipe(autoprefixer({
            browsers: prefix_browsers,
            cascade: false
        }))
        .pipe(sourcemaps.write())
      .pipe(gulp.dest('./css'));
    });

gulp.task('watch',function(){
 		gulp.watch('./dev/styles/*.scss', ['sass']).on('change', livereload.changed)
 		gulp.watch('./dev/jade/*.jade', ['jade']).on('change', livereload.changed)
  });

ps I also have a problem with livereload. The page is reloaded only after the second pressing of ctrl+s. I use sublime plugin + browser plugin + galle plugin.

Answer the question

In order to leave comments, you need to log in

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question