Gulp browserify, uglify with gulp util - zhentian-wan/MEANAppsFiles GitHub Wiki

Browserify, uglify, gutil:

We can use gulp-browserfiy to concat all javascript files together.

npm install gulp-browserfiy --save-dev
var browserfiy = require('gulp-browserfiy'),
    gutil = require('gulp-util');

gulp.task('js', function() {
    return gulp.src('./server.js')  // the enter point
        .pipe(browserify({debug: gutil.env.development})) // only when development env, we add source map
        .pipe(gutil.env.production ? uglify() : gutil.noop()) // only when production, we uglify the code
        .pipe(gulp.dest(output + '/js'));
});