-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
76 lines (69 loc) · 1.54 KB
/
gulpfile.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
var gulp = require('gulp'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
plumber = require('gulp-plumber'),
notify = require('gulp-notify'),
livereload = require('gulp-livereload'),
source = require('vinyl-source-stream'),
browserify = require('browserify'),
watchify = require('watchify'),
streamify = require('gulp-streamify');
var browserifyObj = function() {
return browserify({
cache: {},
packageCache: {},
entries: ['./src/BandsInTownEvents.js'],
debug: true,
standalone: 'BandsInTownEvents'
});
};
//browserify watcher
var watcher = watchify(browserifyObj());
/**
*
* JS Task
*
*
*
*/
var bundleJS = function( bundle ){
return bundle.bundle()
.pipe(plumber({
errorHandler: notify.onError({
title: "Gulp JS",
message: "Error: <%= error.message %>",
sound: "Basso"
})
}))
.pipe(source('bit-events.js'))
// Add transformation tasks to the pipeline here.
.pipe(gulp.dest( './dist/' ))
.pipe(livereload())
.pipe(rename('bit-events.min.js'))
.pipe(streamify(uglify()))
.pipe(gulp.dest( './dist/' ));
}
gulp.task('js', bundleJS.bind(null, browserifyObj()));
/**
*
* Watch Task
* Watching just for JS changes
*
*
*/
gulp.task('watch', function() {
//livereload
livereload.listen();
//bundle our JS right away
bundleJS(watcher);
//watch our JS with watchify
watcher.on('update', bundleJS.bind(null, watcher));
});
/**
*
* Default Task
* Watching just for JS changes
*
*
*/
gulp.task('default', ['watch']);