-
Notifications
You must be signed in to change notification settings - Fork 7
/
gulpfile.js
56 lines (47 loc) · 1.49 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
'use strict';
// https://github.com/gulpjs/gulp/blob/master/docs/recipes/fast-browserify-builds-with-watchify.md
var watchify = require('watchify');
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var gutil = require('gulp-util');
var assign = require('lodash.assign');
var babelify = require("babelify");
var nodemon = require('gulp-nodemon');
var beeper = require('beeper');
// add custom browserify options here
var customOpts = {
entries: ['./client/landing.js'],
transform: [babelify.configure({presets: ["es2015"]})],
debug: true
};
var opts = assign({}, watchify.args, customOpts);
var b = watchify(browserify(opts));
// add transformations here
// i.e. b.transform(coffeeify);
gulp.task('client', bundle);
b.on('update', bundle); // on any dep update, runs the bundler
b.on('log', gutil.log); // output build logs to terminal
function bundle() {
return b.bundle()
// log errors if they happen
.on('error', function(err) {
beeper();
console.log("Browserify error",err);
})
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(gulp.dest('./public'));
}
gulp.task('server', ['client'], function (cb) {
var stream = nodemon({
script: './server/index.js',
watch: './server/'
});
stream.on('crash', function() {
console.error('Tzina crashed :( Restarting in 5 seconds');
stream.emit('restart', 5);
});
});
gulp.task('default', ['server']);