temptest/gulp/backbone.js

36 lines
987 B
JavaScript
Raw Normal View History

2017-10-27 20:26:27 +00:00
'use strict';
2017-11-08 00:51:34 +00:00
const browserify = require('browserify');
const gulp = require('gulp');
const source = require('vinyl-source-stream');
2017-10-27 20:26:27 +00:00
const buffer = require('vinyl-buffer');
2017-11-08 00:51:34 +00:00
const uglify = require('gulp-uglify-es').default;
2017-10-27 20:26:27 +00:00
const sourcemaps = require('gulp-sourcemaps');
2017-11-08 00:51:34 +00:00
const gutil = require('gulp-util');
const rename = require('gulp-rename');
2017-10-27 20:26:27 +00:00
2017-11-08 00:51:34 +00:00
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'))
2017-10-27 20:26:27 +00:00
.pipe(buffer())
.pipe(rename('bundle.js'))
2017-11-08 00:51:34 +00:00
.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'));
2017-10-27 20:26:27 +00:00
});
gulp.task('buildBackbone', ['bundleBackbone'], function() {
gulp.watch('src/backbone/js/**/*.js', ['bundleBackbone']);
});