forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (59 loc) · 1.52 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
var gulp = require('gulp'),
debug = require('debug')('freecc:gulp'),
bower = require('bower-main-files'),
nodemon = require('gulp-nodemon'),
sync = require('browser-sync'),
reload = sync.reload,
inject = require('gulp-inject'),
reloadDelay = 1000;
var paths = {
server: './app.js',
serverIgnore: []
};
gulp.task('inject', function() {
gulp.src('views/home.jade')
.pipe(inject(gulp.src(bower()), {
//ignorePath: '/public'
}))
.pipe(gulp.dest('views'));
});
gulp.task('serve', function(cb) {
var called = false;
nodemon({
script: paths.server,
ext: '.js',
ignore: paths.serverIgnore,
env: {
'NODE_ENV': 'development',
'DEBUG': 'freecc:*'
}
})
.on('start', function() {
if (!called) {
called = true;
setTimeout(function() {
cb();
}, reloadDelay);
}
})
.on('restart', function(files) {
if (files) {
debug('Files that changes: ', files);
}
setTimeout(function() {
debug('Restarting browsers');
reload();
}, reloadDelay);
});
});
gulp.task('sync', ['serve'], function() {
sync.init(null, {
proxy: 'http://localhost:3000',
logLeval: 'debug',
files: ['public/**/*'],
port: 3001,
open: true,
reloadDelay: reloadDelay
});
});
gulp.task('default', ['serve', 'sync']);