-
Notifications
You must be signed in to change notification settings - Fork 0
/
_gulpfile.babel.js
55 lines (46 loc) · 1.24 KB
/
_gulpfile.babel.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
import gulp from 'gulp'
import babel from 'gulp-babel'
import concat from 'gulp-concat'
import plumber from 'gulp-plumber'
import uglify from 'gulp-uglify'
import browserify from 'browserify'
import babelify from 'babelify'
import source from 'vinyl-source-stream'
import buffer from 'vinyl-buffer'
import watchify from 'watchify'
function rebundle() {
bundler.bundle()
.on('error', function(err) {
console.error(err)
this.emit('end')
})
.pipe(source('app.js'))
.pipe(buffer())
.pipe(sourcemaps.init({ loadMaps: true }))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./example/dist'))
}
function watch() {
return compile(true);
}
function app_build(){
var bundler = watchify(browserify('./example/app.js', { debug: true }).transform(babel))
if (watch) {
bundler.on('update', function() {
console.log('-> bundling...')
rebundle();
})
}
rebundle()
return browserify('./example/app.js', { debug: true })
.bundle()
.pipe(source('app.js'))
.pipe(uglify({ mangle: false }))
.pipe(gulp.dest('./example/dist'))
}
const build = gulp.series(
app_build,
watch
)
export { build }
export default build