-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
79 lines (70 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
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 %>",
" * 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", [ "combine.postal" ] );
gulp.task( "combine.postal", function() {
return gulp.src( [ "./src/postal.linked-channels.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( "postal.linked-channels.min.js" ) )
.pipe( gulp.dest( "./lib/" ) );
} );
gulp.task( "default", [ "combine" ] );
gulp.task( "report", function() {
return gulp.src( "./lib/postal.linked-channels.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", [ "combine", "report" ], function() {
if ( !servers ) {
servers = createServer( port );
}
open( "http://localhost:" + port + "/index.html" );
} );