From fdd350e16fd3f6fdfcb5f6f4b793c6502c0a1490 Mon Sep 17 00:00:00 2001 From: Gregory Ballantine Date: Fri, 25 Jul 2025 13:41:51 -0400 Subject: [PATCH] Updated gulpfile to be a little bit less repetitive --- gulpfile.js | 29 ++++++++++++++++++++--------- 1 file changed, 20 insertions(+), 9 deletions(-) diff --git a/gulpfile.js b/gulpfile.js index 1107058..3002acc 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -14,26 +14,37 @@ function compileSass() { // Compile .coffee files to JavaScript with source maps function compileCoffee() { - return gulp.src('assets/scripts/*.coffee', { sourcemaps: true }) + return gulp.src('assets/scripts/**/*.coffee', { sourcemaps: true }) .pipe(plumber()) .pipe(coffee({ bare: true })) .pipe(gulp.dest('public/js', { sourcemaps: '.' })); } // Watch files for changes -function watchFiles() { +function watchFiles(cb) { gulp.watch('assets/styles/**/*.sass', compileSass); gulp.watch('assets/scripts/**/*.coffee', compileCoffee); + cb(); } -// Define default task -exports.default = gulp.series( - gulp.parallel(compileSass, compileCoffee), - watchFiles -); +// Chain all asset builds together +function buildAssets() { + return gulp.parallel(compileSass, compileCoffee); +} + +// Perform initial build then watch +function buildAndWatch() { + return gulp.series( + buildAssets(), + watchFiles + ); +} // one-time build -exports.build = gulp.parallel(compileSass, compileCoffee); +exports.build = buildAssets(); // start builds with file watching -exports.watch = watchFiles; +exports.watch = buildAndWatch(); + +// Define default task (defaults to watch) +exports.default = exports.watch;