-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathgulpfile.js
39 lines (32 loc) · 931 Bytes
/
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
const gulp = require('gulp');
const browserify = require('browserify');
const watchify = require('watchify');
const source = require('vinyl-source-stream');
const notify = require('gulp-notify');
function handleErrors(){
notify.onError({
title: "compile error",
message: "<%= error.message %>"
}).apply(this, arguments);
this.emit('end');
}
gulp.task('build-client', () =>{
const bundler = watchify(browserify({
entries: ["./client/app.jsx", "./client/canvas.js", "./client/webrtc.js"],
debug: true,
transform: [['babelify', {presets: ['es2015','react']}]]
}))
function rebundle(){
var stream = bundler.bundle();
return stream
.on('error', handleErrors)
.pipe(source('bundle.js'))
.pipe(gulp.dest('./client/build/'));
}
bundler.on('update', () => {
rebundle();
console.log('updated');
})
return rebundle();
})
gulp.task('default', ['build-client']);