-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathgulpfile.js
70 lines (62 loc) · 2.05 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
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 rimraf = require("gulp-rimraf");
var gutil = require("gulp-util");
var express = require("express");
var path = require("path");
var tinylr = require("tiny-lr");
var pkg = require("./package.json");
var open = require("open");
var port = 3080;
var banner = ["/**",
" * <%= pkg.name %> - <%= pkg.description %>",
" * Author: <%= pkg.author %>",
" * 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/machina.postal.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("machina.postal.min.js"))
.pipe(gulp.dest("./lib/"));
});
gulp.task("default", function() {
gulp.run("combine");
});
gulp.task("report", function () {
gulp.src("./lib/machina.postal.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" );
});