This repository was archived by the owner on Oct 17, 2019. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
102 lines (76 loc) · 2.18 KB
/
gulpfile.babel.js
File metadata and controls
102 lines (76 loc) · 2.18 KB
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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
import glob from 'glob';
import path from 'path';
import gulp from 'gulp';
import config from './config';
import paths_app from './paths-app';
import paths_vendor from './paths-vendor';
import plugin_libs from 'gulp-load-plugins';
const plugins = plugin_libs();
var paths = {
app: paths_app,
vendor: paths_vendor
};
/********************************************
* Configs And Paths
*********************************************/
/********************************************
* Load Build Tasks
*********************************************/
var buildTasks = loadTasks();
gulp.task('build', buildTasks);
/*********************************************
* Other Tasks
**********************************************/
// Rerun the task when a file changes
gulp.task('watch', function() {
// When jsx script changes recompile scripts
plugins.watch(paths.app.jsx.src, function() {
gulp.start('app-jsx');
});
// When script changes recompile scripts
plugins.watch(paths.app.scripts.src, function() {
gulp.start('app-scripts');
});
// When style changes recompile styles
plugins.watch(paths.app.styles.src, function() {
gulp.start('app-styles');
});
});
// Builds and deploys to github pages
gulp.task('deploy', ['build'], function() {
return gulp.src('./public/**/*')
.pipe(plugins.ghPages());
});
/********************************************
* Serve Task
*********************************************/
gulp.task('serve', function() {
require('./server.js');
});
/********************************************
* Main Tasks
*********************************************/
// // Run this task for development
gulp.task('develop', [
'build',
'serve',
'watch'
]);
gulp.task('default', ['develop']);
/**************************************
* Utils
***************************************/
function loadTasks() {
var taskNames = [];
// Load all tasks from tasks folder
glob.sync('./tasks/*.js').forEach(function(filePath) {
var taskName = path.basename(filePath, '.js');
if(taskName != "app-pages")
taskNames.push(taskName);
if(taskName != "app-pages")
gulp.task(taskName, function() {
require(filePath)(gulp, plugins, paths)
});
});
return taskNames;
}