forked from AustinMahan/Yelp-clone
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
96 lines (81 loc) · 1.84 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
88
89
90
91
92
93
94
95
96
// *** dependencies *** //
const path = require('path');
const gulp = require('gulp');
const jshint = require('gulp-jshint');
const jscs = require('gulp-jscs');
const runSequence = require('run-sequence');
const nodemon = require('gulp-nodemon');
const plumber = require('gulp-plumber');
const server = require('tiny-lr')();
// *** config *** //
const paths = {
scripts: [
path.join('src', '**', '*.js'),
path.join('src', '*.js')
],
styles: [
path.join('src', 'client', 'css', '*.css')
],
views: [
path.join('src', 'server', '**', '*.html'),
path.join('src', 'server', '*.html')
],
server: path.join('src', 'server', 'server.js')
};
const lrPort = 35729;
const nodemonConfig = {
script: paths.server,
ext: 'html js css',
ignore: ['node_modules'],
env: {
NODE_ENV: 'development'
}
};
// *** default task *** //
gulp.task('default', () => {
runSequence(
['lr'],
['nodemon'],
['watch']
);
});
// *** sub tasks ** //
gulp.task('jshint', () => {
return gulp.src(paths.scripts)
.pipe(plumber())
.pipe(jshint({
esnext: true
}))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('jscs', () => {
return gulp.src(paths.scripts)
.pipe(plumber())
.pipe(jscs())
.pipe(jscs.reporter())
.pipe(jscs.reporter('fail'));
});
gulp.task('styles', () => {
return gulp.src(paths.styles)
.pipe(plumber());
});
gulp.task('views', () => {
return gulp.src(paths.views)
.pipe(plumber());
});
gulp.task('lr', () => {
server.listen(lrPort, (err) => {
if (err) {
return console.error(err);
}
});
});
gulp.task('nodemon', () => {
return nodemon(nodemonConfig);
});
gulp.task('watch', () => {
gulp.watch(paths.html, ['html']);
gulp.watch(paths.scripts, ['jshint', 'jscs']);
gulp.watch(paths.styles, ['styles']);
});