'use strict'; const gulp = require('gulp'); const browserify = require('gulp-browserify'); const rename = require('gulp-rename'); const buffer = require('vinyl-buffer'); const sourcemaps = require('gulp-sourcemaps'); gulp.task('bundleBackbone', function() { // Single entry point to browserify gulp.src(['./src/backbone/js/app.js']) .pipe(browserify({ 'insertGlobals' : true, 'debug' : true })) .pipe(buffer()) // optional, remove if you dont want sourcemaps .pipe(sourcemaps.init({ 'loadMaps': true })) // loads map from browserify file // Add transformation tasks to the pipeline here. .pipe(sourcemaps.write('./src/backbone/')) // writes .map file .pipe(rename('bundle.js')) // .pipe(uglify()) .pipe(gulp.dest('./src/backbone/')); }); gulp.task('buildBackbone', ['bundleBackbone'], function() { gulp.watch('src/backbone/js/**/*.js', ['bundleBackbone']); });