I am relatively new to using Gulp for my workflow. Below is my gulpfile.js. I have tried to debug myself and using some hints from another BrowserStack question, but I cant figure it out.
When I save a .php file it reloads the browser, but errors. When I update a scss file, then it completely sass successfully.
const gulp = require( 'gulp' );
const sourcemaps = require( 'gulp-sourcemaps' );
const sass = require('gulp-sass');
const csso = require('gulp-csso');
const autoprefixer = require('gulp-autoprefixer');
const browserSync = require('browser-sync').create();
sass.compiler = require('node-sass');
// Create browsersyn function
function sync(done) {
browserSync.init({
files: './**/*.php',
// Changegit
proxy: 'http://localhost/jacks-bistro'
});
done();
}
// Create sass and sourcemaps function
function sassy() {
return gulp.src('./assets/*.scss')
.pipe( sourcemaps.init() )
.pipe(sass().on('error', sass.logError))
.pipe( autoprefixer() )
.pipe(csso())
.pipe( sourcemaps.write( './' ) )
.pipe(gulp.dest('./'))
.pipe(browserSync.stream());
};
// Create tasks for functions(probably not needed)
gulp.task( "sass", sassy );
gulp.task( "sync", sync );
// Create watch task
gulp.task( 'watch', function () {
gulp.watch('./assets/*.scss', gulp.series('sass'));
gulp.watch('./**/*.php', gulp.series('sync'));
});
This is the error I am receiving:
[23:07:06] 'sync' errored after 815 μs
[23:07:06] TypeError: args.cb is not a function
at Object.init (/Applications/XAMPP/xamppfiles/htdocs/jacks-bistro/wp-content/themes/jb_ewm/node_modules/browser-sync/dist/public/init.js:21:25)
at sync (/Applications/XAMPP/xamppfiles/htdocs/jacks-bistro/wp-content/themes/jb_ewm/gulpfile.js:12:15)
at sync (/Applications/XAMPP/xamppfiles/htdocs/jacks-bistro/wp-content/themes/jb_ewm/node_modules/undertaker/lib/set-task.js:13:15)
at bound (domain.js:430:14)
at runBound (domain.js:443:12)
at asyncRunner (/Applications/XAMPP/xamppfiles/htdocs/jacks-bistro/wp-content/themes/jb_ewm/node_modules/async-done/index.js:55:18)
at processTicksAndRejections (internal/process/task_queues.js:75:11)
I cannot figure out where the error is. Any help would be greatly appreciated.