-
Notifications
You must be signed in to change notification settings - Fork 592
/
gulpfile.js
115 lines (101 loc) · 3.01 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
107
108
109
110
111
112
113
114
115
var beautify = require('gulp-jsbeautifier');
var concat = require('gulp-concat');
var eslint = require('gulp-eslint');
var gulp = require('gulp');
var gulputil = require('gulp-util');
var header = require('gulp-header');
var rename = require('gulp-rename');
var replace = require('gulp-replace');
var todo = require('gulp-todo');
var uglify = require('gulp-uglify');
var webpack = require('webpack-stream');
var moment = require('moment');
var pkg = require('./package.json');
var banner =
'/*!\n\n' +
'<%= pkg.officialName %> - <%= pkg.summary %>\nVersion <%= pkg.version %>+<%= build %>\n' +
'\u00A9 <%= year %> <%= pkg.author.name %> - <%= pkg.author.url %>\n\n' +
'Site: <%= pkg.homepage %>\n' +
'Issues: <%= pkg.bugs.url %>\n' +
'License: <%= pkg.license %>\n\n' +
'*/\n';
function generateBuild() {
var date = new Date;
return Math.floor((date - (new Date(date.getFullYear(), 0, 0))) / 1000).toString(36)
}
var build = generateBuild();
gulp.task('lint', function() {
return gulp.src([
'src/lib/*.js',
'src/lib/renderers/*.js',
'src/renderers/*.js',
'src/index.js'
])
.pipe(eslint())
.pipe(eslint.format())
.pipe(eslint.failAfterError());
});
gulp.task('todo', function() {
return gulp.src([
'src/lib/*.js',
'src/lib/renderers/*.js',
'src/renderers/*.js',
'src/index.js'
])
.pipe(todo())
.pipe(gulp.dest('./'));
});
gulp.task('build', ['lint'], function() {
return gulp.src('src/index.js')
.pipe(webpack({
output: {
library: 'Holder',
filename: 'holder.js',
libraryTarget: 'umd'
}
}))
.pipe(gulp.dest('./'));
});
gulp.task('bundle', ['build'], function() {
return gulp.src([
'src/lib/vendor/polyfills.js',
'holder.js',
'src/meteor/shim.js'
])
.pipe(concat('holder.js'))
.pipe(gulp.dest('./'));
});
gulp.task('minify', ['bundle'], function() {
return gulp.src('holder.js')
.pipe(uglify())
.pipe(rename('holder.min.js'))
.pipe(gulp.dest('./'));
});
gulp.task('banner', ['minify'], function() {
return gulp.src(['holder*.js'])
.pipe(replace('%version%', pkg.version))
.pipe(header(banner, {
pkg: pkg,
year: moment().format('YYYY'),
build: build
}))
.pipe(gulp.dest('./'));
});
gulp.task('beautify', function() {
return gulp.src(['src/lib/*.js'])
.pipe(beautify())
.pipe(gulp.dest('src/lib/'));
});
gulp.task('meteor', function() {
return gulp.src('src/meteor/package.js')
.pipe(replace('%version%', pkg.version))
.pipe(replace('%summary%', pkg.description))
.pipe(gulp.dest('./'));
});
gulp.task('watch', function() {
gulp.watch('src/*.js', ['default']);
});
gulp.task('default', ['bundle', 'minify', 'banner', 'meteor'], function() {
gulputil.log('Finished build ' + build);
build = generateBuild();
});