-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
55 lines (42 loc) · 1.18 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
'use strict';
const _ = require('lodash');
const fs = require('fs');
const path = require('path');
const gulp = require('gulp');
const del = require('del');
const runSequence = require('run-sequence');
const $ = require('gulp-load-plugins')();
const opts = require('./config/gulp');
let exitStatus = 0;
for (const task of fs.readdirSync('./tasks')) {
const file = path.join('./tasks', task);
const taskModule = require(path.resolve(file));
if (typeof taskModule == 'function') {
taskModule(gulp, $, opts);
}
}
gulp.task('clean', function() {
return del('public');
});
gulp.task('build', function(cb) {
runSequence('clean', ['templates', 'browserify', 'images', 'favicon'], 'css', cb);
});
gulp.task('dev', function(cb) {
opts.devMode = true;
const tasks = ['build', 'server', 'watch'];
runSequence.apply(this, tasks.concat(cb));
});
gulp.task('default', ['build']);
function handleErrors(err) {
if (err) {
console.error(err && err.stack);
}
exitStatus = 1;
$.util.beep();
}
process.on('unhandledRejection', handleErrors);
process.on('uncaughtException', handleErrors);
gulp.on('err', handleErrors);
process.on('exit', () => {
process.exit(exitStatus);
});