-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathgulpfile.js
81 lines (73 loc) · 2.06 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
var gulp = require("gulp");
var fileImports = require("gulp-imports");
var header = require("gulp-header");
var beautify = require("gulp-beautify");
var hintNot = require("gulp-hint-not");
var uglify = require("gulp-uglify");
var rename = require("gulp-rename");
var plato = require("gulp-plato");
var gutil = require("gulp-util");
var express = require("express");
var path = require("path");
var pkg = require("./package.json");
var open = require("open");
var port = 3080;
var banner = ["/**",
" * <%= pkg.name %> - <%= pkg.description %>",
" * © 2012 - Copyright appendTo, LLC ",
" * Author(s): Jim Cowart, Nicholas Cloud, Doug Neiner",
" * Version: v<%= pkg.version %>",
" * Url: <%= pkg.homepage %>",
" * License(s): <% pkg.licenses.forEach(function( license, idx ){ %><%= license.type %><% if(idx !== pkg.licenses.length-1) { %>, <% } %><% }); %>",
" */",
""
].join("\n");
gulp.task("combine", function() {
gulp.src(["./src/riveter.js"])
.pipe(header(banner, {
pkg: pkg
}))
.pipe(fileImports())
.pipe(hintNot())
.pipe(beautify({
indentSize: 4,
preserveNewlines: false
}))
.pipe(gulp.dest("./lib/"))
.pipe(uglify({
compress: {
negate_iife: false
}
}))
.pipe(header(banner, {
pkg: pkg
}))
.pipe(rename("riveter.min.js"))
.pipe(gulp.dest("./lib/"));
});
gulp.task("default", function() {
gulp.run("combine");
});
gulp.task("report", function() {
gulp.src("./lib/riveter.js")
.pipe(plato("report"));
});
var createServer = function(port) {
var p = path.resolve("./");
var app = express();
app.use(express.static(p));
app.listen(port, function() {
gutil.log("Listening on", port);
});
return {
app: app
};
};
var servers;
gulp.task("server", function() {
gulp.run("combine", "report");
if (!servers) {
servers = createServer(port);
}
open("http://localhost:" + port + "/index.html");
});