refactor gulpfile to work with gulp v4
This commit is contained in:
parent
29354f0920
commit
238daab855
54
gulpfile.js
54
gulpfile.js
|
|
@ -1,43 +1,47 @@
|
||||||
'use strict';
|
'use strict';
|
||||||
|
|
||||||
var gulp = require('gulp'),
|
const gulp = require('gulp'),
|
||||||
fs = require('fs'),
|
fs = require('fs'),
|
||||||
plumber = require('gulp-plumber');
|
plumber = require('gulp-plumber');
|
||||||
|
|
||||||
var options = {
|
const options = {
|
||||||
source: 'templates',
|
source: 'templates',
|
||||||
dist: 'dist',
|
dist: 'dist',
|
||||||
workingDir: 'tmp',
|
workingDir: 'tmp',
|
||||||
src: function plumbedSrc() {
|
src: function plumbedSrc() {
|
||||||
return gulp
|
return gulp.src.apply(gulp, arguments).pipe(plumber());
|
||||||
.src
|
|
||||||
.apply(gulp, arguments)
|
|
||||||
.pipe(plumber());
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
/** Load tasks from the '/tasks' directory.
|
/**
|
||||||
* Look for .js & .coffee files.
|
* Load tasks from the '/tasks' directory.
|
||||||
* Each file should correspond to a task.
|
|
||||||
*/
|
*/
|
||||||
fs
|
const build = require('./tasks/build')(options);
|
||||||
.readdirSync('./tasks')
|
const checkDeps = require('./tasks/check-deps')(options);
|
||||||
.filter(function readJSFiles(file) {
|
const dupe = require('./tasks/dupe')(options);
|
||||||
return (/\.(js|coffee)$/i).test(file);
|
const less = require('./tasks/less')(options);
|
||||||
})
|
const lint = require('./tasks/lint')(options);
|
||||||
.map(function loadTasks(file) {
|
const postcss = require('./tasks/postcss')(options);
|
||||||
require('./tasks/' + file)(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(
|
gulp.task(
|
||||||
'default',
|
'default',
|
||||||
|
gulp.series(
|
||||||
|
('dupe', 'less', 'sass', 'postcss', 'lint', 'build'),
|
||||||
|
() => {
|
||||||
|
/* gulp will watch for changes in '/templates'. */
|
||||||
|
gulp.watch(
|
||||||
[
|
[
|
||||||
'dupe',
|
options.source + '/**/*.html',
|
||||||
'less',
|
options.source + '/**/*.css',
|
||||||
'sass',
|
options.source + '/**/*.scss',
|
||||||
'postcss',
|
options.source + '/**/*.less',
|
||||||
'lint',
|
options.source + '/**/conf.json'
|
||||||
'build'
|
],
|
||||||
]
|
{ delay: 500 },
|
||||||
|
gulp.series('dupe', 'less', 'sass', 'postcss', 'lint', 'build')
|
||||||
|
)
|
||||||
|
}
|
||||||
|
)
|
||||||
);
|
);
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue