-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
72 lines (60 loc) · 1.74 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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/* Defining global path variables */
gulpPath = __dirname;
modulesPath = __dirname + '/node_modules/';
let gulp = require('gulp');
let requireDir = require('require-dir');
global.x4e = {
config: {},
handlebars: {
helpers: {}
},
tasks: {
preInitial: [],
initial: [],
postInitial: [],
watch: [],
error: []
}
};
//Load all helpers
requireDir('./helpers', {recurse: true});
//Load all project configurations
requireDir('./../src/_config', {recurse: false});
//Load all tasks configurations
requireDir('./tasks', {recurse: false});
// Rerun the task when a file changes
gulp.task('==== watch ====', function () {
let tasks = global.x4e.tasks.watch;
tasks.forEach(function (task) {
gulp.watch(task.options, gulp.series(task.taskName));
});
});
gulp.task('==== preInitial ====', function (done) {
let args = [];
if (global.x4e.tasks.preInitial.length > 0) {
args = global.x4e.tasks.preInitial;
return gulp.parallel(args)(done);
} else {
done();
}
});
gulp.task('==== initial ====', function (done) {
let args = [];
if (global.x4e.tasks.initial.length > 0) {
args = global.x4e.tasks.initial;
gulp.parallel(args)(done);
} else {
done();
}
});
gulp.task('==== postInitial ====', function (done) {
let args = [];
if (global.x4e.tasks.postInitial.length > 0) {
args = global.x4e.tasks.postInitial;
gulp.parallel(args)(done);
} else {
done();
}
});
gulp.task('default', gulp.series('==== preInitial ====', '==== initial ====', '==== postInitial ====', '==== watch ===='));
gulp.task('build', gulp.series('==== preInitial ====', '==== initial ====', '==== postInitial ===='));