-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
45 lines (37 loc) · 1.02 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
const path = require('path')
const gulp = require('gulp')
const browserify = require('browserify')
const source = require('vinyl-source-stream')
const buffer = require('vinyl-buffer')
const sourcemaps = require('gulp-sourcemaps')
const bulkify = require('bulkify')
const es2040 = require('es2040')
const watchify = require('watchify')
gulp.task('build', function () {
const bundler = browserify({
entries: ['./src/index.js'],
debug: true
})
const transforms = [
{ name: es2040, options: {} },
{ name: bulkify, options: {} }
]
transforms.forEach(function (transform) {
bundler.transform(transform.name, transform.options)
})
if (global.isWatching) {
bundler = watchify(bundler)
bundler.on('update', rebundle)
}
return rebundle()
function rebundle () {
bundler.bundle()
.pipe(source('bundle.js'))
.pipe(buffer())
.pipe(gulp.dest(path.join('dist')))
}
})
gulp.task('watch', function () {
gulp.watch('src/**/*.js', ['build'])
})
gulp.task('default', ['build', 'watch'])