-
Notifications
You must be signed in to change notification settings - Fork 243
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
refactor gulpfile to work with gulp v4
- Loading branch information
Showing
1 changed file
with
34 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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') | ||
) | ||
} | ||
) | ||
); |