-
Notifications
You must be signed in to change notification settings - Fork 35
Expand file tree
/
Copy pathgulpfile.babel.js
More file actions
101 lines (91 loc) · 2.11 KB
/
gulpfile.babel.js
File metadata and controls
101 lines (91 loc) · 2.11 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
// NPM Dependencies
import { exec } from 'child_process';
import eslint from 'gulp-eslint';
import gulp from 'gulp';
import nodemon from 'gulp-nodemon';
import notify from 'gulp-notify';
import mocha from 'gulp-mocha';
import remoteSrc from 'gulp-remote-src';
import jsonFormat from 'gulp-json-format';
import concat from 'gulp-concat';
import runSequence from 'run-sequence';
// Vendor task
gulp.task('vendor', () => {
return gulp.src([
'./src/public/bower_components/jquery/dist/jquery.min.js',
'./src/public/js/vendors/ckeditor/basepath.js',
'./src/public/bower_components/ckeditor/ckeditor.js'
])
.pipe(concat('vendor.js'))
.pipe(gulp.dest('./src/public/js/'));
});
// All task
gulp.task('all', () => {
return gulp.src([
'./src/public/js/dashboard/main.js',
'./src/public/js/dashboard/events.js'
])
.pipe(concat('all.js'))
.pipe(gulp.dest('./src/public/js/'));
});
// Mocha task
gulp.task('test', () => {
return gulp.src([
'test/**/*Test.js'
])
.pipe(mocha());
});
// Linter task
gulp.task('analyze', () => {
return gulp.src([
'src/**/*.js',
'test/**/*Test.js',
'!src/public/bower_components/**/*.js',
'!src/public/js/vendors/**/*.js',
'!src/public/js/vendor.js',
'!src/public/js/all.js',
'!src/public/media/**/*.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
// Start Redis
gulp.task('start-redis', () => {
exec('redis-server');
});
// Start dev task
gulp.task('start-dev', () => {
nodemon({
script: 'src/server',
ext: 'js',
ignore: [
'src/public/js/all.js',
'src/public/js/vendor.js'
],
env: {
'NODE_ENV': 'development'
}
})
.on('restart', () => {
runSequence('vendor', 'all');
gulp
.src('src/server')
.pipe(notify('Reloading page, please wait...'));
});
});
// Start production
gulp.task('start', () => {
nodemon({
script: 'src/server',
ext: 'js',
env: {
'NODE_ENV': 'production'
}
});
});
gulp.task('init', () => {
runSequence('vendor', 'all');
});
// Default task
gulp.task('default', ['start-dev', 'init', 'start-redis']);