Thursday 4 May 2017

gulp - uglify js files with browserify?

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?



via teelou

No comments:

Post a Comment