Skip to content

Instantly share code, notes, and snippets.

@danihodovic
Last active August 29, 2015 14:07
Show Gist options
  • Save danihodovic/8c828a0f39cff4e51fb2 to your computer and use it in GitHub Desktop.
Save danihodovic/8c828a0f39cff4e51fb2 to your computer and use it in GitHub Desktop.
Browserify + Esnext + Watch + Errorhandling
var gulp = require('gulp')
var source = require('vinyl-source-stream')
var buffer = require('vinyl-buffer')
var browserify = require('browserify')
var esnext = require('gulp-esnext')
var notify = require('gulp-notify')
var build_dir = './bin'
var browserify_input = './main.js'
var browserify_output = './app.js'
gulp.task('main', function() {
browserify(browserify_input, {})
.bundle()
.on('error', notify.onError(function(err) {
return err.message;
}))
.pipe(source(browserify_output))
.pipe(buffer())
.pipe(esnext())
.pipe(gulp.dest(build_dir))
.pipe(notify({
title: 'Finished',
message: 'Build complete'
}));
})
gulp.task('watch', function() {
gulp.watch('./*.js', ['main'])
})
gulp.task('default', ['main', 'watch'])
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment