Skip to content

Commit

Permalink
refactor gulpfile to work with gulp v4
Browse files Browse the repository at this point in the history
  • Loading branch information
danmindru committed Aug 31, 2019
1 parent 29354f0 commit 238daab
Showing 1 changed file with 34 additions and 30 deletions.
64 changes: 34 additions & 30 deletions gulpfile.js
Original file line number Diff line number Diff line change
@@ -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')
)
}
)
);

0 comments on commit 238daab

Please sign in to comment.