-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
68 lines (59 loc) · 1.71 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
'use strict';
var bs = require('browser-sync');
var gulp = require('gulp');
var exec = require('child_process').exec;
var clear = require('clear');
var nodemon = require('gulp-nodemon');
var config_loader = require('dotenv');
var locals = config_loader.load();
// gulp.task('default', ['nodemon']);
// gulp.task('default', ['nodemon', 'browser-sync',]);
gulp.task('default', ['get-config', 'nodemon', 'browser-sync',]);
gulp.task('get-config', function(cb) {
if (exec("heroku config -s > .env"))
cb();
});
gulp.task('browser-sync', ['nodemon'], function() {
bs.init(null, {
proxy: "http://localhost:5000",
files: ["client/**/*.*"],
browser: "chrome",
port: "5001",
// reloadOnRestart: true,
});
});
function load_frontend() {
console.log('-------- Starting browser-sync (frontend loader) --------');
bs.reload();
}
gulp.task('nodemon', function (cb) {
var started = false;
var reloaded = false;
return nodemon({
env: locals,
watch: [
"server.js",
"server/",
],
})
.on('start', function () {
// to avoid nodemon being started multiple times
if (!started) {
cb();
started = true;
}
if (!load_frontend()) {
load_frontend();
}
})
.on('restart', function() {
// clear();
console.log('-------- Restarting Server --------');
})
.on('crash', function() {
// clear();
console.log('-------- APP CRASHED! Make sure you have valid Heroku credentials --------');
console.log("-------- Type 'rs' [enter] on THIS command line to RESTART server --------");
load_frontend();
});
});