gulp - uglify js files with browserify?

laukok

I am following the example from here exactly and have my own version:

gulp.task('build-js', function() {
    var bundler = browserify('js/*.js');

    return bundler.pipe()
        .pipe(source('bundle.min.js'))
        .pipe(buffer())
        .pipe(sourcemaps.init())
        .pipe(uglify())
        .pipe(sourcemaps.write('./maps'))
        .pipe(gulp.dest('dist'))
        .pipe(livereload());
});

But why do I get this error:

$ gulp
[21:48:33] Using gulpfile /var/www/html/mysite/gulpfile.js
[21:48:33] Starting 'apply-prod-environment'...
Setting NODE_ENV to 'production'
Successfully set NODE_ENV to production
[21:48:33] Finished 'apply-prod-environment' after 169 μs
[21:48:33] Starting 'build-js'...
[21:48:33] 'build-js' errored after 11 ms
[21:48:33] TypeError: bundler.pipe is not a function

What have I missed?

E_net4 the downvoter

It seems that example provided by vinyl-buffer has a mistake: You must call bundle() before adding transforms, not pipe():

return bundler.bundle()
    .pipe(source('bundle.min.js'))
    .pipe(buffer())
    .pipe(sourcemaps.init())
    .pipe(uglify())
    .pipe(sourcemaps.write('./maps'))
    .pipe(gulp.dest('dist'))
    .pipe(livereload());

Another example is provided in the Gulp repository (one should indeed use the browserify API directly in Gulp).

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

From Java

How to uglify output with Browserify in Gulp?

From Java

Using Gulp to Concatenate and Uglify files

From Dev

Gulp Browserify combine JS

From Dev

gulp.js+browserify: Dynamically generate development-specific files

From Dev

gulp.js+browserify: Dynamically generate development-specific files

From Dev

How to get sourcemaps for gulp+babel+browserify+uglify

From Dev

Gulp, concat and uglify files and concat with vendor

From Dev

Gulp uglify output min.js

From Dev

Gulp uglify fails with js parse error

From Dev

How can I uglify my bundle files for React with gulp?

From Dev

Gulp browserify JS but replace revision references like gulp-usemin

From Dev

Gulp/uglify - bundle does not compress to bundle.js

From Dev

CSS and JS minification doesn't work with gulp-filter, gulp-csso, gulp-uglify

From Dev

Gulp uglify and save license

From Dev

Basic Gulp Uglify Setup?

From Dev

gulp: uglify and sourcemaps

From Dev

Gulp Uglify Options not applying

From Dev

Basic Gulp Uglify Setup?

From Dev

Use glob matching, when passing files to browserify in gulp

From Dev

Using Browserify on only a subset of files in a folder within a Gulp task

From Dev

Gulp with browserify: Cannot find module src/js/main.js

From Dev

how to serve node.js code for browsers with automatic browserify+uglify

From Dev

uglify merging multi js files into single js file with minified

From Dev

How to use grunt-contrib-uglify to gzip the js files also?

From Dev

Concat and Uglify JS Files from Two Different Sources using Grunt

From Dev

Is it possible to only minify unminified JS files with grunt uglify

From Dev

grunt: how to detect if file is saved to uglify all of my js files

From Dev

How do I uglify my AngularJS 2 Typescript app files and wire up for a production release using Gulp

From Dev

Gulp ngmin + uglify not working properly

Related Related

  1. 1

    How to uglify output with Browserify in Gulp?

  2. 2

    Using Gulp to Concatenate and Uglify files

  3. 3

    Gulp Browserify combine JS

  4. 4

    gulp.js+browserify: Dynamically generate development-specific files

  5. 5

    gulp.js+browserify: Dynamically generate development-specific files

  6. 6

    How to get sourcemaps for gulp+babel+browserify+uglify

  7. 7

    Gulp, concat and uglify files and concat with vendor

  8. 8

    Gulp uglify output min.js

  9. 9

    Gulp uglify fails with js parse error

  10. 10

    How can I uglify my bundle files for React with gulp?

  11. 11

    Gulp browserify JS but replace revision references like gulp-usemin

  12. 12

    Gulp/uglify - bundle does not compress to bundle.js

  13. 13

    CSS and JS minification doesn't work with gulp-filter, gulp-csso, gulp-uglify

  14. 14

    Gulp uglify and save license

  15. 15

    Basic Gulp Uglify Setup?

  16. 16

    gulp: uglify and sourcemaps

  17. 17

    Gulp Uglify Options not applying

  18. 18

    Basic Gulp Uglify Setup?

  19. 19

    Use glob matching, when passing files to browserify in gulp

  20. 20

    Using Browserify on only a subset of files in a folder within a Gulp task

  21. 21

    Gulp with browserify: Cannot find module src/js/main.js

  22. 22

    how to serve node.js code for browsers with automatic browserify+uglify

  23. 23

    uglify merging multi js files into single js file with minified

  24. 24

    How to use grunt-contrib-uglify to gzip the js files also?

  25. 25

    Concat and Uglify JS Files from Two Different Sources using Grunt

  26. 26

    Is it possible to only minify unminified JS files with grunt uglify

  27. 27

    grunt: how to detect if file is saved to uglify all of my js files

  28. 28

    How do I uglify my AngularJS 2 Typescript app files and wire up for a production release using Gulp

  29. 29

    Gulp ngmin + uglify not working properly

HotTag

Archive