2
2
3
3
import gulp from 'gulp' ;
4
4
import gulpif from 'gulp-if' ;
5
- import gutil from 'gulp-util' ;
6
5
import source from 'vinyl-source-stream' ;
7
6
import sourcemaps from 'gulp-sourcemaps' ;
8
7
import buffer from 'vinyl-buffer' ;
@@ -15,6 +14,7 @@ import browserSync from 'browser-sync';
15
14
import debowerify from 'debowerify' ;
16
15
import ngAnnotate from 'browserify-ngannotate' ;
17
16
import handleErrors from '../util/handleErrors' ;
17
+ import bundleLogger from '../util/bundleLogger' ;
18
18
import config from '../config' ;
19
19
20
20
// Based on: http://blog.avisi.nl/2014/04/25/how-to-keep-a-fast-build-with-browserify-and-reactjs/
@@ -33,10 +33,7 @@ function buildScript(file) {
33
33
if ( ! global . isProd ) {
34
34
bundler = watchify ( bundler ) ;
35
35
36
- bundler . on ( 'update' , function ( ) {
37
- rebundle ( ) ;
38
- gutil . log ( 'Rebundle...' ) ;
39
- } ) ;
36
+ bundler . on ( 'update' , rebundle ) ;
40
37
}
41
38
42
39
const transforms = [
@@ -52,10 +49,14 @@ function buildScript(file) {
52
49
} ) ;
53
50
54
51
function rebundle ( ) {
52
+ bundleLogger . start ( ) ;
53
+
55
54
const stream = bundler . bundle ( ) ;
56
55
const sourceMapLocation = global . isProd ? './' : '' ;
57
56
58
- return stream . on ( 'error' , handleErrors )
57
+ return stream
58
+ . on ( 'error' , handleErrors )
59
+ . on ( 'end' , bundleLogger . end )
59
60
. pipe ( source ( file ) )
60
61
. pipe ( gulpif ( shouldCreateSourcemap , buffer ( ) ) )
61
62
. pipe ( gulpif ( shouldCreateSourcemap , sourcemaps . init ( { loadMaps : true } ) ) )
0 commit comments