Last active
February 13, 2024 07:55
-
-
Save alyssaq/bc8b1a34d5d8f3a753da to your computer and use it in GitHub Desktop.
browserify, babel, gulp, glob, vinyl-source-stream, uglify
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/* | |
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