-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
49 lines (37 loc) · 973 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
40
41
42
43
44
45
46
47
48
49
var gulp = require('gulp');
var _ = require('underscore');
var browserify = require('browserify');
var watchify = require('watchify');
var source = require('vinyl-source-stream');
var gutil = require('gulp-util');
var connect = require('gulp-connect');
function build(watch) {
var inputs = ['./js/app.js'];
var outputLocation = './build/';
var customOpts = {
entries: inputs
};
var opts = _.extend(customOpts, watchify.args);
var b = watchify(browserify(opts));
function bundle() {
gutil.log('Bundling...')
b.bundle()
.pipe(source('app.bundle.js'))
.pipe(gulp.dest(outputLocation));
gutil.log('Bundled.')
}
bundle();
if (watch) {
b.on('update', bundle);
}
};
gulp.task('webserver', function() {
connect.server();
});
gulp.task('default', ['webserver']);
gulp.task('build', function () {
build();
});
gulp.task('watch', function () {
build(true);
});