diff --git a/gulpfile.js b/gulpfile.js index 867239f..979019a 100644 --- a/gulpfile.js +++ b/gulpfile.js @@ -1,43 +1,47 @@ 'use strict'; -var gulp = require('gulp'), - fs = require('fs'), - plumber = require('gulp-plumber'); +const gulp = require('gulp'), + fs = require('fs'), + plumber = require('gulp-plumber'); -var options = { +const options = { source: 'templates', dist: 'dist', workingDir: 'tmp', - src: function plumbedSrc(){ - return gulp - .src - .apply(gulp, arguments) - .pipe(plumber()); + src: function plumbedSrc() { + return gulp.src.apply(gulp, arguments).pipe(plumber()); } }; -/** Load tasks from the '/tasks' directory. - * Look for .js & .coffee files. - * Each file should correspond to a task. +/** + * Load tasks from the '/tasks' directory. */ -fs - .readdirSync('./tasks') - .filter(function readJSFiles(file) { - return (/\.(js|coffee)$/i).test(file); - }) - .map(function loadTasks(file) { - require('./tasks/' + file)(options); - }); +const build = require('./tasks/build')(options); +const checkDeps = require('./tasks/check-deps')(options); +const dupe = require('./tasks/dupe')(options); +const less = require('./tasks/less')(options); +const lint = require('./tasks/lint')(options); +const postcss = require('./tasks/postcss')(options); +const sass = require('./tasks/sass')(options); -/** By default templates will be built into '/dist', then gulp will watch for changes in '/src'. */ +/* By default templates will be built into '/dist' */ gulp.task( - 'default', - [ - 'dupe', - 'less', - 'sass', - 'postcss', - 'lint', - 'build' - ] + 'default', + gulp.series( + ('dupe', 'less', 'sass', 'postcss', 'lint', 'build'), + () => { + /* gulp will watch for changes in '/templates'. */ + gulp.watch( + [ + options.source + '/**/*.html', + options.source + '/**/*.css', + options.source + '/**/*.scss', + options.source + '/**/*.less', + options.source + '/**/conf.json' + ], + { delay: 500 }, + gulp.series('dupe', 'less', 'sass', 'postcss', 'lint', 'build') + ) + } + ) );