'use strict'; const browserify = require('browserify'); const gulp = require('gulp'); const source = require('vinyl-source-stream'); const buffer = require('vinyl-buffer'); const uglify = require('gulp-uglify-es').default; const sourcemaps = require('gulp-sourcemaps'); const gutil = require('gulp-util'); const rename = require('gulp-rename'); gulp.task('bundleES', function () { // set up the browserify instance on a task basis const b = browserify({ 'debug': true, 'entries': './src/es2016/js/app.js' }); return b.bundle() .pipe(source('app.js')) .pipe(buffer()) .pipe(rename('bundle.js')) .pipe(sourcemaps.init({ 'loadMaps': true })) // Add transformation tasks to the pipeline here. .pipe(uglify()) .on('error', gutil.log) .pipe(sourcemaps.write('.')) .pipe(gulp.dest('./src/es2016')); }); gulp.task('buildES', ['bundleES'], function() { gulp.watch('src/es2016/js/**/*.js', ['bundleES']); });