A
A
Alyosha2017-04-25 21:19:56
Node.js
Alyosha, 2017-04-25 21:19:56

Where did I go wrong with gulp > browsersync + sass?

'use strict';
const gulp = require('gulp');
const browserSync = require('browser-sync').create();
const sass = require('gulp-sass');

gulp.task('sass', function () {
  return gulp.src('public/css/scss/*.{css,scss}')
    .pipe(sass.sync().on('error', sass.logError))
    .pipe(gulp.dest('public/css/'));
});

gulp.task('serve', function() {
  browserSync.init(
  {
    proxy:'w23/public/',
    port:8080
  }
  // {server: "public/"}
  );
  browserSync.watch('public/**/*.*').on('change', browserSync.reload);
gulp.watch('public/css/scss/*.{css,scss}', ['sass']);
});

gulp.task('default', gulp.series('clear','sass','serve'));

Gives an error message:
Error: watching public/css/scss/*.{css,scss}: watch task has to be a function (optionally generated by using gulp.parallel or gulp.series)
at Gulp.watch (D:\OpenServer\domains\w23 \node_modules\gulp\index.js:28:11)
at D:\OpenServer\domains\w23\gulpfile.js:125:6
at taskWrapper (D:\OpenServer\domains\w23\node_modules\undertaker\lib\set- task.js:13:15)
at bound (domain.js:280:14)
at runBound (domain.js:293:12)
at asyncRunner (D:\OpenServer\domains\w23\node_modules\async-done\index. js:36:18)
at _combinedTickCallback (internal/process/next_tick.js:67:7)
at process._tickDomainCallback (internal/process/next_tick.js:122:9)

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Alyosha, 2017-04-25
@GIBRID21

Xs, in general, what was the matter, did everything as in the manual (. https://browsersync.io/docs/gulp#page-top) - it did not work.
Will work if:

browserSync.watch('public/**/*.*').on('change', browserSync.reload);
gulp.watch('public/css/scss/*.{css,scss}', ['sass']);

Replaced by:
gulp.watch("public/**/*.*").on('change', gulp.series('sass',browserSync.reload));

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question