L
L
Lesha Gnibeda2020-08-17 13:40:50
css
Lesha Gnibeda, 2020-08-17 13:40:50

Browser sync not working on gulp, what should I do?

I don't understand why this code doesn't work. I want to refresh the page when scss changes, but in the console this code gives an error and does not start

const gulp = require('gulp');
const sass = require('gulp-sass');
const sourcemaps = require('gulp-sourcemaps');
const watch = require('gulp-watch');
const browserSync = require('browser-sync').create();

function sasscompile(done){
   gulp.src('./scss/**/*.scss')
  .pipe(sourcemaps.init())
  .pipe(sass().on('error', sass.logError))
  .pipe(sourcemaps.write('./'))
  .pipe(gulp.dest('./css/'))
  .pipe(browserSync.stream());
  done();
}

function watchsass(done){
  gulp.watch('./scss/**/*.scss', gulp.series('sasscompile'));
  done();
}

function browsersync(done){
  browserSync.init({
    server: {
      baseDir:'./'
    },
    port: 3000
  });
  done();
}

gulp.task('default', gulp.parallel(watchsass, browsersync));

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