-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
50 lines (41 loc) · 1.08 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
"use strict";
const gulp = require( 'gulp' ),
browserify = require( 'browserify' ),
del = require( 'del' ),
source = require( 'vinyl-source-stream' ),
buffer = require( 'vinyl-buffer' ),
watchify = require('watchify'),
assign = require('lodash.assign'),
gutil = require('gutil'),
uglify = require('gulp-uglify'),
pump = require('pump')
;
let customOpts = {
entries: ['./example/index.js'],
debug: true
};
let opts = assign({ transform: ['brfs'] }, watchify.args, customOpts),
watch = watchify(browserify(opts))
;
gulp.task('dev', bundle);
watch.on('update', bundle);
watch.on('log', gutil.log);
gulp.task('default', ['dev']);
function bundle() {
return watch.bundle()
.on('error', gutil.log.bind(gutil, 'Browserify Error'))
.pipe(source('bundle.js'))
.pipe(gulp.dest('./build/js'))
;
}
gulp.task( 'js', function () {
return browserify( './example/index.js' )
.transform( 'babelify', { presets: ['es2015'] } )
.bundle()
.pipe( source( 'bundle.js' ) )
.pipe(gulp.dest('./build/js'))
.pipe( buffer() )
.pipe( uglify() )
.pipe(gulp.dest('./build/js'))
;
} );