-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.babel.js
60 lines (48 loc) · 1.33 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
'use strict';
import gulp from 'gulp';
import requireDir from 'require-dir';
import runSequence from 'run-sequence';
import gulpHelp from 'gulp-help';
import { ENV, IS_PRODUCTION, ARGV, log } from './gulp-tasks/gulp-config/config';
gulpHelp(gulp);
/* No need of separate task files for these */
gulp.task('set-dev-node-env', () => {
return process.env.NODE_ENV = ENV.dev;
});
gulp.task('set-prod-node-env', () => {
return process.env.NODE_ENV = ENV.prod;
});
/********************************************/
requireDir('./gulp-tasks');
// Build Task
gulp.task('build', 'Script building Task', (done) => {
const allTasks = ['scripts'];
if (IS_PRODUCTION) {
allTasks.unshift('set-prod-node-env');
} else {
allTasks.unshift('set-dev-node-env');
}
runSequence(...allTasks, () => {
done();
});
});
// Default Task
gulp.task('default', 'Default Task', (done) => {
const allTasks = ['clean', 'scripts'];
if (IS_PRODUCTION) {
allTasks.unshift('set-prod-node-env');
} else {
allTasks.unshift('set-dev-node-env');
if (!ARGV.unwatch) {
allTasks[allTasks.indexOf('scripts')] = 'forever';
}
}
runSequence(...allTasks, () => {
done();
});
}, {
options: {
'unwatch': 'Development mode, no watch, default watch the files',
'type=production': 'Run on production, Default is development'
}
});