Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save juanmirod/3583133422616db50b1c6487e9b46b8c to your computer and use it in GitHub Desktop.
Save juanmirod/3583133422616db50b1c6487e9b46b8c to your computer and use it in GitHub Desktop.
Working gulp task that transpiles and bundles the application using Babel 6.0, ES2015 preset and Browserify
var gulp = require('gulp');
var babel = require('babelify');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
/*
Transpiles the code using babel and es2015 preset and then bundles
the application in a file.
*/
gulp.task('bundle', function() {
var bundler = browserify('./app/main.js', { debug: true })
.transform(babel.configure({
presets: ["es2015"]
}));
bundler.bundle()
.on('error', function(err) { console.error(err); this.emit('end'); })
.pipe(source('build.js'))
.pipe(buffer())
.pipe(gulp.dest('./dist/js'));
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment