This repository has been archived by the owner on May 4, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathgulpfile.babel.js
61 lines (49 loc) · 1.56 KB
/
gulpfile.babel.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
import fs from 'fs';
import gulp from 'gulp';
import yaml from 'yamljs';
import paths from './gulp/paths';
import * as pipelines from './gulp/pipelines';
const gulpPlugins = require('gulp-load-plugins')();
const watchers = [];
const watch = (...args) => {
watchers.push(args);
};
const resourcesTasks = [];
const depsBuild = ['resources'];
const depsDev = ['watch', 'build'];
/*
Load all tasks from the ./gulp/tasks folder.
They all need to export a function that takes the following parameters:
* gulp -> the gulp instance to use
* paths -> the object of paths to use
* gulpPlugins -> an object of auto loaded gulp plugins
* watch -> a watch function that you must use to add watches (same syntax as gulp.watch)
Each function can return an object that can contain a build and/or dev key, which has
a task name as a value. This task will be added as a dependency to the build or dev
task respectively.
*/
const taskFolder = './gulp/tasks';
fs.readdirSync(taskFolder).forEach(function(file) {
const deps = require(`${taskFolder}/${file}`).default(gulp, paths, gulpPlugins, watch, pipelines) || {};
if (deps.build) {
depsBuild.push(deps.build);
}
if (deps.dev) {
depsDev.push(deps.dev);
}
if (deps.resources) {
resourcesTasks.push(deps.resources);
}
});
/**
* Task to watch all fils, that different tasks added to the watcher list.
*/
gulp.task('watch', () => {
watchers.forEach((watcher) => {
gulp.watch(...watcher);
});
});
gulp.task('resources', resourcesTasks);
gulp.task('build', depsBuild);
gulp.task('dev', depsDev);
gulp.task('default', ['build']);