-
-
Notifications
You must be signed in to change notification settings - Fork 3
/
gulpfile.js
95 lines (74 loc) · 2.09 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
'use strict';
var del = require('del'),
gulp = require('gulp'),
jshint = require('gulp-jshint'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename'),
umd = require('gulp-umd');
var umdNamespace = function() {
return 'hkjs';
};
// ============================================================================
// PUBLIC TASKS
// ============================================================================
gulp.task('build-examples', gulp.series(
clean('./examples/assets/hookahjs'),
buildJs('./examples/assets/hookahjs')
));
gulp.task('build-dist', gulp.series(
clean('./dist'),
gulp.parallel(
buildJs('./dist'),
buildUmdJs('./dist')
)
));
gulp.task('build-tests', gulp.series(
clean('./test/assets/hookahjs'),
buildJs('./test/assets/hookahjs')
));
gulp.task('build-all', gulp.parallel(
'build-examples',
'build-dist',
'build-tests'
));
// ============================================================================
// PRIVATE TASKS
// ============================================================================
function makeTask(displayName, fn) {
if (displayName) fn.displayName = displayName;
return fn;
}
function clean(dirname) {
return makeTask('clean: ' + dirname, function(done) {
return del(dirname, done);
});
}
function buildJs(dirname) {
return makeTask('build-js: ' + dirname, function() {
return gulp.src('src/hookah.js')
.pipe(umd({
namespace: umdNamespace,
template: 'umd-templates/web.js'
}))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(rename('hookah.js'))
.pipe(gulp.dest(dirname))
.pipe(uglify())
.pipe(rename('hookah.min.js'))
.pipe(gulp.dest(dirname));
});
}
function buildUmdJs(dirname) {
return makeTask('build-umd-js: ' + dirname, function() {
return gulp.src('src/hookah.js')
.pipe(umd({
namespace: umdNamespace,
template: 'umd-templates/UMD.js'
}))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(rename('hookah.umd.js'))
.pipe(gulp.dest(dirname));
});
}