Skip to content

Instantly share code, notes, and snippets.

@alyssaq
Last active February 13, 2024 07:55
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 2 You must be signed in to fork a gist
  • Save alyssaq/bc8b1a34d5d8f3a753da to your computer and use it in GitHub Desktop.
Save alyssaq/bc8b1a34d5d8f3a753da to your computer and use it in GitHub Desktop.
browserify, babel, gulp, glob, vinyl-source-stream, uglify
/*
npm install gulp gulp-load-plugins gulp-uglify
npm install browserify babelify glob vinyl-source-stream vinyl-buffer
More examples: https://github.com/gulpjs/gulp/tree/master/docs/recipes
*/
var gulp = require('gulp')
var $ = require('gulp-load-plugins')()
var browserify = require('browserify')
var babelify = require('babelify')
var glob = require('glob')
var source = require('vinyl-source-stream')
var buff = require('vinyl-buffer')
gulp.task('browserify', function () {
var files = glob.sync('./app/scripts/**/*.js');
return browserify({
entries: files,
debug: true
})
.transform(babelify)
.bundle()
.pipe(source('bundle.js'))
.pipe(buff())
.pipe($.uglify())
.pipe(gulp.dest('dest/scripts'));
});
/* Do not use vinyl-transform https://github.com/substack/node-browserify/issues/1191 */
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment