@@ -9,8 +9,7 @@ Browserify with transforms and full sourcemaps that resolve to the original indi
9
9
10
10
var browserify = require (' browserify' );
11
11
var gulp = require (' gulp' );
12
- var source = require (' vinyl-source-stream' );
13
- var buffer = require (' vinyl-buffer' );
12
+ var transform = require (' vinyl-transform' );
14
13
var uglify = require (' gulp-uglify' );
15
14
var sourcemaps = require (' gulp-sourcemaps' );
16
15
@@ -20,25 +19,19 @@ var getBundleName = function () {
20
19
return version + ' .' + name + ' .' + ' min' ;
21
20
};
22
21
23
- gulp .task (' javascript' , function () {
24
-
25
- var bundler = browserify ( {
26
- entries : [ ' ./app.js ' ],
27
- debug : true
22
+ gulp .task (' javascript' , function () {
23
+ // transform regular node stream to gulp (buffered vinyl) stream
24
+ var browserified = transform ( function ( filename ) {
25
+ var b = browserify (filename);
26
+ return b . bundle ();
28
27
});
29
-
30
- var bundle = function () {
31
- return bundler
32
- .bundle ()
33
- .pipe (source (getBundleName () + ' .js' ))
34
- .pipe (buffer ())
35
- .pipe (sourcemaps .init ({loadMaps: true }))
28
+
29
+ return gulp .src (' ./app.js' )
30
+ .pipe (browserified)
31
+ .pipe (sourcemaps .init ({loadMaps: true }))
36
32
// Add transformation tasks to the pipeline here.
37
33
.pipe (uglify ())
38
- .pipe (sourcemaps .write (' ./' ))
39
- .pipe (gulp .dest (' ./dist/js/' ));
40
- };
41
-
42
- return bundle ();
34
+ .pipe (sourcemaps .write (' ./' ))
35
+ .pipe (gulp .dest (' ./dist/js/' ));
43
36
});
44
37
```
0 commit comments