This repository has been archived by the owner on Mar 20, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
57 lines (50 loc) · 1.42 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
(function (gulp) {
"use strict";
const umd = require('gulp-umd'),
nodeunit = require('gulp-nodeunit'),
babel = require('gulp-babel'),
uglify = require('gulp-uglify'),
rename = require('gulp-rename');
let path = {
test: './test/**/*.test.js',
source: './src/**/*',
dist: './dist'
};
// Build module for ES5
gulp.task('umd', () => {
return gulp.src(path.source)
.pipe(babel({
presets: ['es2015']
}))
.pipe(umd())
.pipe(gulp.dest(path.dist));
});
// Build module for ES2015 (ES6)
gulp.task('es2015umd', () => {
return gulp.src(path.source)
.pipe(umd())
.pipe(rename({
prefix: 'Es2015-'
}))
.pipe(gulp.dest(path.dist));
});
// Tests
gulp.task('test', ['umd', 'es2015umd'], () => {
return gulp.src(path.test)
.pipe(nodeunit());
});
// Compress ES5 module
gulp.task('uglify', ['test'], () => {
return gulp.src([
path.dist + '/*.js',
'!' + path.dist + '/*.min.js',
'!' + path.dist + '/Es2015*.js'
])
.pipe(uglify())
.pipe(rename({
suffix: '.min'
}))
.pipe(gulp.dest(path.dist));
});
gulp.task('default', ['uglify']);
})(require('gulp'));