forked from kubetail-org/loadjs
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
95 lines (74 loc) · 2.08 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 'loadjs';
};
// ============================================================================
// PUBLIC TASKS
// ============================================================================
gulp.task('build-examples', gulp.series(
clean('./examples/assets/loadjs'),
buildJs('./examples/assets/loadjs')
));
gulp.task('build-dist', gulp.series(
clean('./dist'),
gulp.parallel(
buildJs('./dist'),
buildUmdJs('./dist')
)
));
gulp.task('build-tests', gulp.series(
clean('./test/assets/loadjs'),
buildJs('./test/assets/loadjs')
));
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/loadjs.js')
.pipe(umd({
namespace: umdNamespace,
template: 'umd-templates/web.js'
}))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(rename('loadjs.js'))
.pipe(gulp.dest(dirname))
.pipe(uglify())
.pipe(rename('loadjs.min.js'))
.pipe(gulp.dest(dirname));
});
}
function buildUmdJs(dirname) {
return makeTask('build-umd-js: ' + dirname, function() {
return gulp.src('src/loadjs.js')
.pipe(umd({
namespace: umdNamespace,
template: 'umd-templates/UMD.js'
}))
.pipe(jshint())
.pipe(jshint.reporter('default'))
.pipe(rename('loadjs.umd.js'))
.pipe(gulp.dest(dirname));
});
}