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:
27
gulpfile.js
27
gulpfile.js
@ -14,26 +14,37 @@ function compileSass() {
|
|||||||
|
|
||||||
// Compile .coffee files to JavaScript with source maps
|
// Compile .coffee files to JavaScript with source maps
|
||||||
function compileCoffee() {
|
function compileCoffee() {
|
||||||
return gulp.src('assets/scripts/*.coffee', { sourcemaps: true })
|
return gulp.src('assets/scripts/**/*.coffee', { sourcemaps: true })
|
||||||
.pipe(plumber())
|
.pipe(plumber())
|
||||||
.pipe(coffee({ bare: true }))
|
.pipe(coffee({ bare: true }))
|
||||||
.pipe(gulp.dest('public/js', { sourcemaps: '.' }));
|
.pipe(gulp.dest('public/js', { sourcemaps: '.' }));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Watch files for changes
|
// Watch files for changes
|
||||||
function watchFiles() {
|
function watchFiles(cb) {
|
||||||
gulp.watch('assets/styles/**/*.sass', compileSass);
|
gulp.watch('assets/styles/**/*.sass', compileSass);
|
||||||
gulp.watch('assets/scripts/**/*.coffee', compileCoffee);
|
gulp.watch('assets/scripts/**/*.coffee', compileCoffee);
|
||||||
|
cb();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Define default task
|
// Chain all asset builds together
|
||||||
exports.default = gulp.series(
|
function buildAssets() {
|
||||||
gulp.parallel(compileSass, compileCoffee),
|
return gulp.parallel(compileSass, compileCoffee);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Perform initial build then watch
|
||||||
|
function buildAndWatch() {
|
||||||
|
return gulp.series(
|
||||||
|
buildAssets(),
|
||||||
watchFiles
|
watchFiles
|
||||||
);
|
);
|
||||||
|
}
|
||||||
|
|
||||||
// one-time build
|
// one-time build
|
||||||
exports.build = gulp.parallel(compileSass, compileCoffee);
|
exports.build = buildAssets();
|
||||||
|
|
||||||
// start builds with file watching
|
// 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