forked from freeCodeCamp/freeCodeCamp
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
87 lines (78 loc) · 1.95 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
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
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,
less = require('gulp-less'),
path = require('path'),
eslint = require('gulp-eslint');
var paths = {
server: './server/server.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': process.env.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/js/lib/*/*.{js, jsx}'],
port: 3001,
open: false,
reloadDelay: reloadDelay
});
});
gulp.task('lint', function() {
return gulp.src(['public/js/lib/**/*'])
.pipe(eslint())
.pipe(eslint.format());
});
gulp.task('less', function() {
return gulp.src('./public/css/*.less')
.pipe(less({
paths: [ path.join(__dirname, 'less', 'includes') ]
}))
.pipe(gulp.dest('./public/css/'));
});
gulp.task('build', ['less']);
gulp.task('watch', ['less', 'serve', 'sync'], function() {
gulp.watch('./public/css/*.less', ['less']);
});
gulp.task('default', ['less', 'serve', 'sync', 'watch']);