Move tasks to separate files and simplify
This commit is contained in:
parent
dde26ec45e
commit
06ba111392
12 changed files with 1560 additions and 1030 deletions
|
|
@ -1,23 +1,24 @@
|
|||
const src = 'source/';
|
||||
const dest = 'build/';
|
||||
const dev = 'build/';
|
||||
const dpl = 'deploy/';
|
||||
const rep = 'reports/';
|
||||
|
||||
const config = {
|
||||
src: src,
|
||||
dest: dest,
|
||||
dev: dev,
|
||||
dpl: dpl,
|
||||
rep: rep,
|
||||
|
||||
demo: true,
|
||||
|
||||
//these are not used while demo: true is set
|
||||
index: 'index.html',
|
||||
|
||||
templateData: src + 'templates/data.json',
|
||||
frontendData: src + 'data/**/*.json',
|
||||
|
||||
hippie: {
|
||||
brand: 'hippie',
|
||||
titlePrefix: ' - HIPPIE',
|
||||
pageBase: './',
|
||||
jsFile: 'main',
|
||||
jsonFile: 'db'
|
||||
pageBase: './'
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
25
gulp/modules/plumber.js
Normal file
25
gulp/modules/plumber.js
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
const plumber = require('gulp-plumber');
|
||||
// const notify = require('gulp-notify');
|
||||
|
||||
// function catchErrors(errTitle) {
|
||||
// return plumber({
|
||||
// errorHandler: notify.onError({
|
||||
// // Customizing error title
|
||||
// title: errTitle || "GULP GENERAL PROBLEM",
|
||||
// message: "<%= error.message %>"
|
||||
// })
|
||||
// });
|
||||
// }
|
||||
|
||||
function catchErrors() {
|
||||
return plumber({
|
||||
errorHandler: function (err) {
|
||||
// Logs error in console
|
||||
console.log(err.message);
|
||||
// Ends the current pipe, so Gulp watch doesn't break
|
||||
this.emit('end');
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
module.exports = catchErrors;
|
||||
9
gulp/tasks/clean.js
Normal file
9
gulp/tasks/clean.js
Normal 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
6
gulp/tasks/hello.js
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
function hello (cb) {
|
||||
console.log('He Stephan', cb);
|
||||
cb();
|
||||
}
|
||||
|
||||
module.exports = hello;
|
||||
25
gulp/tasks/sync.js
Normal file
25
gulp/tasks/sync.js
Normal 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
13
gulp/tasks/validate.js
Normal 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;
|
||||
Loading…
Add table
Add a link
Reference in a new issue