Skip to content

Commit

Permalink
Rewrite Gulpfile to use latest syntax
Browse files Browse the repository at this point in the history
  • Loading branch information
maxxcrawford committed Jun 11, 2021
1 parent 54a8751 commit 90c87a0
Showing 1 changed file with 28 additions and 37 deletions.
65 changes: 28 additions & 37 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
const gulp = require('gulp');
const { src, watch, series, dest } = require('gulp');
const sass = require('gulp-sass');
const del = require('del');
const merge = require('merge-stream');
Expand All @@ -7,53 +7,44 @@ const merge = require('merge-stream');
const buildDir = 'static/scss/libs/';
const finalDir = 'static/css/';

// Compile all SASS/SCSS into => app.scss
gulp.task('styles', () => {
return gulp.src('static/scss/app.scss')
.pipe(sass().on('error', sass.logError))
.pipe(gulp.dest(finalDir));
});

// Clean out compiled CSS folder
gulp.task('clean', () => {
return del([
function clean(cb) {
del([
finalDir
]);
});
cb();
}

// On setup, remove
gulp.task('setup', () => {
return del([
function reset(cb) {
del([
finalDir,
buildDir,
]);
});
cb();
}

function styles(cb) {
src('static/scss/app.scss')
.pipe(sass().on('error', sass.logError))
.pipe(dest(finalDir));

cb();
}

function assetsCopy() {
return merge([
function assetsCopy(cb) {
merge([
// SASS and LESS go to build dir
gulp.src([
src([
'!node_modules/@mozilla-protocol/core/*',
'node_modules/@mozilla-protocol/core/**/*',
])
.pipe(gulp.dest(buildDir)),
.pipe(dest(buildDir)),
]);
cb();
}

const buildTask = gulp.series([
'setup',
assetsCopy,
'styles',
]);

gulp.task('build', buildTask);

gulp.task('default', async () => {
// Build on first run
gulp.series(buildTask);

// Watch for SCSS changes
gulp.watch('static/scss/**/*.scss', (done) => {
gulp.series(['clean', 'styles'])(done);
});
});
exports.default = series(
reset, assetsCopy, styles, function() {
// You can use a single task
watch('static/scss/**/*.scss', { ignoreInitial: false }, series(clean, styles));
}
);

0 comments on commit 90c87a0

Please sign in to comment.