-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
64 lines (54 loc) · 1.45 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
var gulp = require('gulp');
var uglify = require('gulp-uglify');
var concat = require('gulp-concat');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var watchify = require('watchify');
var nodemon = require('gulp-nodemon');
var babelify = require('babelify');
gulp.task('watch',function(){
var start = Date.now();
var watchJS = watchify(browserify({
entries:'./src/main.js',
transform:babelify,
debug:true,
cache: {}, packageCache: {}, fullPaths: true
})
);
return watchJS.on('update',function(){
watchJS.bundle()
.on('error', function(err) { console.log('Error updating bundle'); })
.pipe(source('bundle.js'))
.pipe(gulp.dest('./client/build'));
console.log('updated at ' + (Date.now() - start) + ' ms ago');
})
.bundle()
.pipe(source('bundle.js'))
.pipe(gulp.dest('./client/build'));
});
gulp.task('build',function(){
return browserify({
entries:'./src/main.js',
transform:babelify,
debug:true
}).bundle()
.on('error',function(err){
console.log(err)
console.log(err.message)
})
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(concat('bundle.js'))
.pipe(uglify())
.pipe(gulp.dest('./client/build'));
});
gulp.task('server',function(){
nodemon({
script:'./server/server.js',
ext:'html js',
ignore: ['client']
});
});
gulp.task('default',
['server','build','watch']);