-
Notifications
You must be signed in to change notification settings - Fork 25
/
Copy pathgulpfile.js
88 lines (74 loc) · 1.94 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
77
78
79
80
81
82
83
84
85
86
87
88
'use strict';
var browserify = require('browserify');
var gulp = require('gulp');
var source = require('vinyl-source-stream');
var buffer = require('vinyl-buffer');
var sourcemaps = require('gulp-sourcemaps');
var webserver = require('gulp-webserver');
var jshint = require('gulp-jshint');
var watch = require('gulp-watch');
var karma = require('karma');
var preprocessify = require('preprocessify');
var getBundleName = function () {
return 'sww';
};
gulp.task('tests', function () {
new karma.Server({
configFile: __dirname + '/testing/karma-sw.conf.js',
singleRun: false
}).start();
});
gulp.task('bundle-dist', function() {
var bundler = browserify({
entries: ['./index.js'],
debug: false,
standAlone: 'ServiceWorkerWare'
});
var bundle = function() {
return bundler
.transform(preprocessify())
.bundle()
.pipe(source(getBundleName() + '.js'))
.pipe(buffer())
.pipe(gulp.dest('./dist/'));
};
return bundle();
});
gulp.task('bundle-debug', function() {
var bundler = browserify({
entries: ['./index.js'],
debug: true,
standAlone: 'ServiceWorkerWare'
});
var bundle = function() {
return bundler
.transform(preprocessify(
{ DEBUG: true }
))
.bundle()
.pipe(source(getBundleName() + '.js'))
.pipe(buffer())
.pipe(sourcemaps.init({loadMaps: true}))
.pipe(sourcemaps.write('./'))
.pipe(gulp.dest('./dist/'));
};
return bundle();
});
gulp.task('webserver', function() {
gulp.src('.')
.pipe(webserver({
livereload: true,
directoryListing: true,
open: true
}));
});
gulp.task('watch', function() {
gulp.watch('./lib/*', ['lint', 'javascript']);
});
gulp.task('lint', function() {
return gulp.src(['./lib/**/*.js', './index.js'])
.pipe(jshint())
.pipe(jshint.reporter('default'));
});
gulp.task('default', ['lint','bundle-dist']);
gulp.task('debug', ['lint', 'bundle-debug'])