Updated gulpfile to be a little bit less repetitive
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
This commit is contained in:
29
gulpfile.js
29
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;
|
||||
|
Reference in New Issue
Block a user