-
Notifications
You must be signed in to change notification settings - Fork 71
/
gulpfile.js
60 lines (49 loc) · 1.98 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
const { series, task, watch } = require('gulp');
const { TARGETS, BUILD_DESTS, TARGETS_BUILD_DESTS, WATCH_GLOBS } = require('./gulp/config');
const { checkRequiredEnvVars, loadEnvFile } = require('./gulp/env');
const copy = require('./gulp/copy');
const css = require('./gulp/css');
const html = require('./gulp/html');
const manifest = require('./gulp/manifest');
const pack = require('./gulp/pack');
const remove = require('./gulp/remove');
const script = require('./gulp/script');
const start = require('./gulp/start');
const taskName = process.argv[2];
const targetName = process.argv.pop();
const targetNames = ['all', ...Object.values(TARGETS)];
if (!targetName || !targetNames.includes(targetName)) {
console.error(`Pass one of possible target names: "${targetNames.join('", "')}"`);
process.exit(1);
}
loadEnvFile();
checkRequiredEnvVars(taskName, targetName);
const createBuildDestSeries = buildDest => {
return series(
remove.bind(null, buildDest),
copy.bind(null, buildDest),
css.bind(null, buildDest),
script.bind(null, buildDest),
html.bind(null, buildDest),
manifest.bind(null, buildDest)
);
};
let buildTasks;
let startTasks;
let packTasks;
if (targetName === 'all') {
buildTasks = series(
...Object.values(BUILD_DESTS).map(buildDest => createBuildDestSeries(buildDest))
);
startTasks = series(...Object.values(TARGETS).map(targetName => start.bind(null, targetName)));
packTasks = series(...Object.values(TARGETS).map(targetName => pack.bind(null, targetName)));
} else {
buildTasks = createBuildDestSeries(TARGETS_BUILD_DESTS[targetName]);
startTasks = start.bind(null, targetName);
packTasks = pack.bind(null, targetName);
}
task('dev', buildTasks);
task('watch', watch.bind(null, WATCH_GLOBS, { ignoreInitial: false }, buildTasks));
task('start', series(buildTasks, startTasks, watch.bind(null, WATCH_GLOBS, buildTasks)));
task('build', buildTasks);
task('pack', series(buildTasks, packTasks));