forked from Sonoport/webaudioloader
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGulpfile.js
More file actions
89 lines (71 loc) · 2.14 KB
/
Gulpfile.js
File metadata and controls
89 lines (71 loc) · 2.14 KB
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
89
"use strict";
var pkg = require('./package.json');
var gulp = require('gulp');
var jshint = require('gulp-jshint');
var rename = require('gulp-rename');
var uglify = require('gulp-uglify');
var header = require('gulp-header');
var webserver = require('gulp-webserver');
var browserify = require('browserify');
var source = require('vinyl-source-stream');
var paths = {
jssrc : './lib/*.js',
jsentry: './lib/webaudioloader.js',
test : './test/',
dist : './dist',
testspecs : './test/spec/webaudioloader.spec.js'
}
var banner= '/*<%= pkg.name %> - v<%= pkg.version %> - ' +
'<%= new Date() %> */ \n';
gulp.task('jshint', function(){
return gulp.src([paths.jssrc])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('browserify', ['jshint'], function () {
var b = browserify({
entries: paths.jsentry,
standalone: pkg.name
});
return b.bundle()
.pipe(source(paths.jssrc))
.pipe(header(banner, {pkg: pkg}))
.pipe(rename('webaudioloader.js'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('standalone', ['browserify'], function () {
return gulp.src(['dist/webaudioloader.js'])
.pipe(uglify({mangle: false, preserveComments: 'all'}))
.pipe(rename('webaudioloader.min.js'))
.pipe(gulp.dest(paths.dist));
});
gulp.task('jshint:test', function(){
return gulp.src([paths.testspecs])
.pipe(jshint('.jshintrc'))
.pipe(jshint.reporter('jshint-stylish'))
.pipe(jshint.reporter('fail'));
});
gulp.task('browserify:test',['jshint:test'], function () {
var b = browserify({
entries: paths.testspecs,
debug: true
});
return b.bundle()
.pipe(source(paths.testspecs))
.pipe(rename('test.js'))
.pipe(gulp.dest(paths.test));
});
gulp.task('watch:src', function(){
gulp.watch(paths.jssrc, ['browserify']);
});
gulp.task('watch:test', function(){
gulp.watch(paths.testspecs, ['browserify:test']);
});
gulp.task('test', ['jshint', 'browserify:test', 'watch:test', 'watch:src'], function(){
return gulp.src([paths.test, paths.dist])
.pipe(webserver({
port: 8080,
host : "localhost"
}));
});