forked from ibolmo/openshift-express-example
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
45 lines (36 loc) · 1.22 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
const gulp = require('gulp');
const concat = require('gulp-concat');
const nodemon = require('gulp-nodemon');
const livereload = require('gulp-livereload');
const wait = require('gulp-wait');
gulp.task('css', () => gulp.src('public/**/*.css').pipe(livereload()));
const jsFiles = [
'./node_modules/whatwg-fetch/fetch.js',
'./node_modules/socket.io-client/socket.io.js',
];
gulp.task('js', () => {
gulp.src(jsFiles)
.pipe(concat('main.js'))
.pipe(gulp.dest('./public/js/'));
});
gulp.task('jade', () => gulp.src('views/**/*.jade').pipe(livereload()));
gulp.task('watch', () => {
gulp.watch('public/**/*.css', ['css']);
gulp.watch('public/**/*.js', ['js']);
gulp.watch('views/**/*.jade', ['jade']);
});
gulp.task('start', () => {
livereload.listen();
nodemon({
verbose: 'true',
script: 'server.js', // file that starts server
ext: 'js', // which files to restart server
env: { NODE_ENV: 'development' }, // environment variables
}).on('start', () => {
gulp.src('server.js')
.pipe(wait(500)) // prevent browser 'offline'
.pipe(livereload());
});
});
gulp.task('build', ['js']);
gulp.task('default', ['start', 'watch']);