traintimesPWA/gulp/backbone.js

67 lines
1.7 KiB
JavaScript
Raw Normal View History

2017-12-15 18:34:59 +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');
2018-02-12 12:37:18 +00:00
const stripDebug = require('gulp-strip-debug');
2019-01-17 23:46:38 +00:00
const bump = require('gulp-bump');
2017-12-15 18:34:59 +00:00
gulp.task('bundleBackbone', function () {
// set up the browserify instance on a task basis
const b = browserify({
'debug': true,
'entries': './src/js/app.js'
});
return b.bundle()
.pipe(source('app.js'))
.pipe(buffer())
2019-01-17 23:46:38 +00:00
// .pipe(stripDebug())
2017-12-15 18:34:59 +00:00
.pipe(rename('bundle.js'))
.pipe(sourcemaps.init({ 'loadMaps': true }))
// Add transformation tasks to the pipeline here.
// .pipe(uglify())
2017-12-15 18:34:59 +00:00
.on('error', gutil.log)
.pipe(sourcemaps.write('.'))
.pipe(gulp.dest('./live/js'));
});
2019-01-19 22:47:39 +00:00
gulp.task('liveBackbone', function () {
// set up the browserify instance on a task basis
const b = browserify({
'debug': true,
'entries': './src/js/app.js'
});
return b.bundle()
.pipe(source('app.js'))
.pipe(buffer())
.pipe(stripDebug())
.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('./live/js'));
});
2019-01-17 23:46:38 +00:00
gulp.task('bump', function() {
gulp.src('src/service-worker.js')
.pipe(bump({ 'key': 'version' }))
.pipe(gulp.dest('src'))
.pipe(gulp.dest('live'));
});
gulp.task('buildBackbone', ['bump', 'bundleBackbone'], function() {
gulp.watch('src/js/**/*.js', ['bump', 'bundleBackbone']);
2017-12-15 18:34:59 +00:00
});