'use strict';

var gulp = require( 'gulp' );
var $ = require( 'gulp-load-plugins' )();
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var pkg = require( '../config' ).pkg;
var banner = require( '../config' ).banner;
var config = require( '../config' ).scripts;
var handleErrors = require( '../utils/handleErrors' );

gulp.task( 'scripts', function() {
  var b = browserify({
    entries: config.entrypoint,
    debug: true
  });

  b.bundle()
    .pipe( source( 'main.js' ) )
    .pipe( buffer())
    .pipe( $.sourcemaps.init( { loadMaps: true } ) )
    .pipe( $.uglify() )
    .pipe( $.sourcemaps.write( './' ) )
    .pipe( gulp.dest( config.dest ) );
} );

@@ -615,24 +615,57 @@
  true %7D ) )%0A
+    .on( 'error', handleErrors )%0A
     .pipe( $

handle script errors