Move tasks to separate files and simplify

This commit is contained in:
Stephan Hagedorn 2021-03-09 22:54:56 +01:00
parent dde26ec45e
commit 06ba111392
12 changed files with 1560 additions and 1030 deletions

9
gulp/tasks/clean.js Normal file
View file

@ -0,0 +1,9 @@
const config = require('../config');
const del = require('del');
// Clean output folders
function clean() {
return del([config.dev + '**', config.rep + '**', config.dpl + '**']);
}
module.exports = clean;

6
gulp/tasks/hello.js Normal file
View file

@ -0,0 +1,6 @@
function hello (cb) {
console.log('He Stephan', cb);
cb();
}
module.exports = hello;

25
gulp/tasks/sync.js Normal file
View file

@ -0,0 +1,25 @@
const config = require('../config');
const browserSync = require('browser-sync'), server = browserSync.create();
// Automagically reload browsers
function reload(done) {
server.reload();
done();
}
// Serve files to the browser
function serve(done) {
server.init({
index: config.index,
open: false,
server: config.dev
});
done();
}
module.exports = {
serve: serve,
reload: reload,
};

13
gulp/tasks/validate.js Normal file
View file

@ -0,0 +1,13 @@
const { src } = require('gulp');
const config = require('../config');
const plumber = require('../modules/plumber');
const htmlValidator = require('gulp-w3c-html-validator');
function validate() {
return src(config.dev + '**/*.html')
.pipe(plumber())
.pipe(htmlValidator())
.pipe(htmlValidator.reporter());
}
module.exports = validate;