-
Notifications
You must be signed in to change notification settings - Fork 1
/
gulpfile.js
99 lines (91 loc) · 2.44 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
var gulp = require('gulp'),
browserify = require('browserify'),
moment = require('moment'),
uglify = require('gulp-uglify'),
gzip = require('gulp-gzip'),
header = require('gulp-header'),
buffer = require('vinyl-buffer'),
collapse = require('bundle-collapser/plugin'),
source = require('vinyl-source-stream'),
pkg = require('./package.json'),
UGLIFY_OPTS = {
fromString: true,
mangle: {
sort: true,
toplevel: true,
eval: true
},
compress: {
screw_ie8: true,
properties: true,
unsafe: true,
sequences: true,
dead_code: true,
conditionals: true,
booleans: true,
unused: true,
if_return: true,
join_vars: true,
drop_console: true,
comparisons: true,
loops: true,
cascade: true,
warnings: true,
negate_iife: true,
pure_getters: true
}
};
var banner = function() {
var head = [
'/*! ${title} - v${version} - ${date} %>\n',
' * ${homepage}\n',
' * Copyright (c) 2013-${year} ${author}; License: ${license} */\n'
].join('');
return header(head, {
title: pkg.title || pkg.name,
version: pkg.version,
date: moment().format('YYYY-MM-DD'),
homepage: pkg.homepage,
author: pkg.author.name,
year: moment().format('YYYY'),
license: pkg.license
});
};
var build = function() {
return browserify('./src/index.js', {
standalone: 'storge',
debug: false
})
.plugin(collapse)
.bundle();
};
var min = function() {
return build()
.pipe(source('storge.min.js'));
};
gulp.task('build', function() {
build()
.pipe(source('storge.js'))
.pipe(buffer())
.pipe(banner())
.pipe(gulp.dest('./'));
});
gulp.task('min', function() {
min()
.pipe(buffer())
.pipe(uglify(UGLIFY_OPTS))
.pipe(banner())
.pipe(gulp.dest('./'));
});
gulp.task('zip', function() {
min()
.pipe(gzip({ append: true }))
.pipe(gulp.dest('./'));
});
gulp.task('release', function() {
gulp.start([
'build',
'min',
'zip'
]);
});