V
V
Vitalik Cherny2016-06-18 11:01:43
JavaScript
Vitalik Cherny, 2016-06-18 11:01:43

Live Reload fails when compiling sass(scss) incorrectly. How to automate the process?

"use strict";

var gulp = require('gulp'),
  sass = require('gulp-sass'),
  watch = require('gulp-watch'),
  browserSync = require('browser-sync').create();

gulp.task('serve', ['sass'], function() {

  browserSync.init({
    server: "./app"
  });

  gulp.watch("app/sass/*.scss", ['sass']);
  gulp.watch("app/*.html").on('change', browserSync.reload);
});


gulp.task('sass', function() {
  return gulp.src("app/sass/*.scss")
    .pipe(sass())
    .pipe(gulp.dest("app/css"))
    .pipe(browserSync.stream());
});

gulp.task('default', ['serve']);

1856453e4b474441a6840ccf0820bccb.png

Answer the question

In order to leave comments, you need to log in

2 answer(s)
S
sim3x, 2016-06-18
@Devinora

pipe(
      sass()
      .on('error', sass.logError)
)

V
Vitalik Cherny, 2016-06-18
@Devinora

"use strict";

var gulp = require('gulp'),
  sass = require('gulp-sass'),
  watch = require('gulp-watch'),
  browserSync = require('browser-sync').create(),
  plumber = require('gulp-plumber');

gulp.task('serve', ['sass'], function() {

  browserSync.init({
    server: "./app"
  });

  gulp.watch("app/sass/*.scss", ['sass']);
  gulp.watch("app/*.html").on('change', browserSync.reload);
});


gulp.task('sass', function() {
  return gulp.src("app/sass/*.scss")
    .pipe(plumber())
    .pipe(sass())
    .pipe(gulp.dest("app/css"))
    .pipe(browserSync.stream());
});

gulp.task('default', ['serve']);

26e6b2afe27e40ce9d6f91b6076b75fb.png

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question