From e1ae4f8b5f9652b1783fdfc48a9103aa144d7e2c Mon Sep 17 00:00:00 2001 From: matt Date: Wed, 16 Feb 2022 14:10:30 +0000 Subject: [PATCH] Document gulpfile for writeup --- gulpfile.js | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/gulpfile.js b/gulpfile.js index 3a625df..21eee5c 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,13 +1,16 @@ 'use strict'; +// Import required modules const del = require('del'); const gulp = require('gulp'); const postcss = require('gulp-postcss'); const sass = require('gulp-sass')(require('sass')); +// Set src and destination paths for css compilation const src = 'src/stylesheets/main.scss'; const dest = 'public/css'; +// Task to compile and optimise css from sass file gulp.task('styles', () => { let cssnanoOptions = { normalizeWhitespace: false @@ -30,14 +33,17 @@ gulp.task('styles', () => { .pipe(gulp.dest(dest)); }); +// Task to clean up the destination directory gulp.task('clean', () => { return del([ dest ]); }); +// When called with no task, clean the destination, and then compile styles gulp.task('default', gulp.series([ 'clean', 'styles' ])); +// Task to watch for changes in sass files, then compile on changes gulp.task('watch', () => { gulp.watch('src/stylesheets/**/*.scss', (done) => { gulp.series([ 'clean', 'styles' ])(done);