I am struggling to understand the error regarding browser-sync in gulp 4, as there is no clear documentation about it. Even in the gulp 4 documentation, the usage of "async" is not clear. How can I troubleshoot and fix this issue? Thank you. bla bla bla bla bla bla bla bla bla bla
'default' errored after 23 ms
The following tasks did not complete: browser-sync
Did you forget to signal async completion?
var gulp = require('gulp'),
gutil = require('gulp-util' ),
sass = require('gulp-sass'),
browserSync = require('browser-sync'),
concat = require('gulp-concat'),
uglify = require('gulp-uglify'),
cleancss = require('gulp-clean-css'),
rename = require('gulp-rename'),
autoprefixer = require('gulp-autoprefixer'),
notify = require('gulp-notify');
gulp.task('browser-sync', function() {
browserSync({
server: {
baseDir: 'app'
},
notify: false,
// open: false,
// online: false, // Work Offline Without Internet Connection
// tunnel: true, tunnel: "projectname", // Demonstration page: http://projectname.localtunnel.me
})
});
gulp.task('styles', function() {
return gulp.src('app/'+syntax+'/**/*.'+syntax+'')
.pipe(sass({ outputStyle: 'expanded' }).on("error", notify.onError()))
.pipe(rename({ suffix: '.min', prefix : '' }))
.pipe(autoprefixer(['last 15 versions']))
.pipe(cleancss( {level: { 1: { specialComments: 0 } } }))
.pipe(gulp.dest('app/css'))
.pipe(browserSync.stream())
});
gulp.task('scripts', function() {
return gulp.src([
'app/libs/jquery/dist/jquery.min.js',
'app/js/common.js',
])
.pipe(concat('scripts.min.js'))
.pipe(uglify())
.pipe(gulp.dest('app/js'))
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('code', function() {
return gulp.src('app/*.html')
.pipe(browserSync.reload({ stream: true }))
});
gulp.task('watch', function() {
gulp.watch('app/'+syntax+'/**/*.'+syntax+'', gulp.parallel('styles'));
gulp.watch(['libs/**/*.js', 'app/js/common.js'], gulp.parallel('scripts'));
gulp.watch('app/*.html', gulp.parallel('code'))
});
gulp.task('default', gulp.parallel('watch', 'browser-sync'));