temptest/gulp/backbone.js
2017-11-08 00:51:34 +00:00

36 lines
987 B
JavaScript

'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('bundleBackbone', function () {
// set up the browserify instance on a task basis
const b = browserify({
'debug': true,
'entries': './src/backbone/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/backbone'));
});
gulp.task('buildBackbone', ['bundleBackbone'], function() {
gulp.watch('src/backbone/js/**/*.js', ['bundleBackbone']);
});