-
Notifications
You must be signed in to change notification settings - Fork 5
/
gulpfile.js
83 lines (71 loc) · 2.02 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
var gulp = require('gulp'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
server = require('gulp-express'),
connect = require('gulp-connect-multi')();
//$ = require('gulp-load-plugins')();
// Scripts
gulp.task('scripts-client', function () {
return browserify({
entries: ['./app/js/client-example.jsx'],
debug: true
})
.on('error', function(log) {
console.log(log);
})
.bundle()
.on('error', function(log) {
console.log(log);
})
.pipe(source('client.js'))
// .pipe($.jshint('.jshintrc'))
// .pipe($.jshint.reporter('default'))
.pipe(gulp.dest('app/js'))
.pipe(connect.reload())
//.on('error', $.util.beep);
});
gulp.task('scripts-server', function () {
return browserify({
entries: ['./app/js/server-example.jsx'],
debug: true
})
.on('error', function(log) {
console.log(log);
})
.bundle()
.on('error', function(log) {
console.log(log);
})
.pipe(source('server.js'))
// .pipe($.jshint('.jshintrc'))
// .pipe($.jshint.reporter('default'))
.pipe(gulp.dest('app/js'))
//start the server at the beginning of the task
.pipe(server.run({
file: 'app.js'
}));
//.on('error', $.util.beep);
});
//styles
gulp.task('styles', function() {
//for now just reload the server
connect.reload();
});
// Connect
gulp.task('connect', connect.server({
root: ['app'],
port: 9003,
livereload: true,
open:{
browser: 'Google Chrome' //'chrome'
}
}));
gulp.task('watch-client', ['scripts-client', 'connect'], function () {
gulp.watch(['app/js/**/*.js','app/js/**/*.jsx','!app/js/app.js','!app/js/client.js'], ['scripts-client']);
gulp.watch(['app/css/**.css'], ['styles']);
});
gulp.task('watch-server', ['scripts-server', 'connect'], function () {
gulp.watch(['app/js/**/*.js','app/js/**/*.jsx','!app/js/app.js'], ['scripts-server']);
gulp.watch(['app/css/**.css'], ['styles']);
});
gulp.task('default', ['watch-client']);