2018-02-23 10:36:49 +00:00
|
|
|
'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');
|
|
|
|
const stripDebug = require('gulp-strip-debug');
|
|
|
|
|
|
|
|
gulp.task('bundleBackbone', function () {
|
|
|
|
// set up the browserify instance on a task basis
|
|
|
|
const b = browserify({
|
|
|
|
'debug': true,
|
|
|
|
'entries': './src/v1/js/app.js'
|
|
|
|
});
|
|
|
|
|
|
|
|
return b.bundle()
|
|
|
|
.pipe(source('app.js'))
|
|
|
|
.pipe(buffer())
|
2018-02-27 11:02:22 +00:00
|
|
|
.pipe(stripDebug())
|
2018-02-23 10:36:49 +00:00
|
|
|
.pipe(rename('bundle.js'))
|
|
|
|
|
|
|
|
.pipe(sourcemaps.init({ 'loadMaps': true }))
|
|
|
|
// Add transformation tasks to the pipeline here.
|
2018-02-27 11:02:22 +00:00
|
|
|
.pipe(uglify())
|
2018-02-23 10:36:49 +00:00
|
|
|
.on('error', gutil.log)
|
|
|
|
.pipe(sourcemaps.write('.'))
|
|
|
|
.pipe(gulp.dest('./live/js'));
|
|
|
|
});
|
|
|
|
|
|
|
|
gulp.task('buildBackbone', ['bundleBackbone'], function() {
|
|
|
|
gulp.watch('src/v1/js/**/*.js', ['bundleBackbone']);
|
|
|
|
});
|
|
|
|
|