Skip to content

Instantly share code, notes, and snippets.

@byverdu
Last active May 30, 2017 22:57
Show Gist options
  • Save byverdu/5a205ece24324279d3ea6333e5cfa801 to your computer and use it in GitHub Desktop.
Save byverdu/5a205ece24324279d3ea6333e5cfa801 to your computer and use it in GitHub Desktop.
// build/tasks/browserify.js
const gulp = require( 'gulp' );
const browserify = require( 'browserify' );
const uglify = require( 'gulp-uglify' );
const source = require( 'vinyl-source-stream' );
const gutil = require( 'gulp-util' );
const buffer = require( 'vinyl-buffer' );
const sourcemaps = require( 'gulp-sourcemaps' );
const notify = require( 'gulp-notify' );
const babelify = require( 'babelify' );
gulp.task( 'browserify', () => {
// set up the browserify instance on a task basis
const b = browserify({
entries: './app/client/js/router.js',
debug: true,
transform: [babelify]
});
return b.bundle()
.pipe( source( 'bundle.js' ))
.pipe( buffer())
.pipe( sourcemaps.init({ loadMaps: true }))
// Add transformation tasks to the pipeline here.
.pipe( uglify({ mangle: true }))
.on( 'error', gutil.log )
.pipe( sourcemaps.write( './' ))
.pipe( gulp.dest( './app/client/static' ))
.pipe( notify({ message: 'Browserify completed' }));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment