-
Notifications
You must be signed in to change notification settings - Fork 4
/
gulpfile.js
106 lines (91 loc) · 2.7 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
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
var gulp = require("gulp"),
uglify = require("gulp-uglify"),
header = require("gulp-header"),
footer = require("gulp-footer"),
concat = require("gulp-concat"),
static = require("node-static");
/**
* Concat all files from ./lib into ./polyplayer.js
* No vendors are included
*/
gulp.task("build", function() {
gulp.src([
"./lib/player.js",
"./lib/playlist.js",
"./lib/model.js",
"./lib/soundcloud.js",
"./lib/youtube.js",
"./lib/vimeo.js"
])
.pipe(concat("polyplayer.js"))
.pipe(header({ file: "./assets/header.txt" }))
.pipe(footer({ file: "./assets/footer.txt" }))
.pipe(gulp.dest("./"));
});
/**
* Concat and minify all files from ./lib into ./polyplayer.js
* No vendors are included
*/
gulp.task("build-minify", function() {
gulp.src([
"./lib/player.js",
"./lib/playlist.js",
"./lib/model.js",
"./lib/soundcloud.js",
"./lib/youtube.js",
"./lib/vimeo.js"
])
.pipe(concat("polyplayer.min.js"))
.pipe(header({ file: "./assets/header.txt" }))
.pipe(footer({ file: "./assets/footer.txt" }))
.pipe(uglify())
.pipe(gulp.dest("./"));
});
/**
* Concat and minify all files from ./lib into ./polyplayer.js
* All vendors (vimeo (froogaloop.js)) are included
*/
gulp.task("build-vendor", function() {
gulp.src([
"./vendor/froogaloop.js",
"./lib/player.js",
"./lib/playlist.js",
"./lib/model.js",
"./lib/soundcloud.js",
"./lib/youtube.js",
"./lib/vimeo.js"
])
.pipe(concat("polyplayer.vendor.min.js"))
.pipe(header({ file: "./assets/header.txt" }))
.pipe(footer({ file: "./assets/footer.txt" }))
.pipe(uglify())
.pipe(gulp.dest("./"));
});
/**
* Development task
* Run `build` for each change in ./lib
* Start static server on localhost:4444
*/
gulp.task("default", function() {
var file = new static.Server();
require("http").createServer(function (request, response) {
request.addListener("end", function () {
file.serve(request, response, function(e, rsp) {
if (e && e.status === 404) {
response.writeHead(e.status, e.headers);
response.end("Not Found");
}
});
}).resume();
}).listen(4444);
gulp.run("build");
gulp.watch("./lib/*.js", function() {
gulp.run("build");
});
});
/**
* Build polyplayer.js, polyplayer.min.js and polyplayer.vendor.min.js
*/
gulp.task("all", function() {
gulp.run("build", "build-minify", "build-vendor");
});