forked from FrDH/dotdotdot-js
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
67 lines (58 loc) · 1.73 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
const gulp = require('gulp'),
terser = require('gulp-terser'),
typescript = require('gulp-typescript'),
rename = require('gulp-rename'),
replace = require('gulp-replace');
const transpile = (target, module) => {
return (
gulp
.src('src/*.ts')
// First, we transpile back to JS.
.pipe(
typescript({
target: target,
module: module
})
)
// Next, uglify it.
.pipe(
terser({
output: {
comments: '/^!/'
}
})
)
);
};
/** Save plugin to be used without UMD pattern or ES6 module. */
const js = cb => {
return transpile('es5', 'es6')
.pipe(rename('dotdotdot.js'))
.pipe(replace('export default Dotdotdot;', ''))
.pipe(gulp.dest('dist'));
};
/** Save plugin to be used as an ES6 module. */
const jsES6 = cb => {
return transpile('es6', 'es6')
.pipe(rename('dotdotdot.es6.js'))
.pipe(gulp.dest('dist'));
};
/** Save plugin to be used with bundlers that support the pkg.module definition. */
const jsESM = cb => {
return transpile('es5', 'es6')
.pipe(rename('dotdotdot.esm.js'))
.pipe(gulp.dest('dist'));
};
/** Save plugin to be used with UMD pattern. */
const jsUMD = cb => {
return transpile('es5', 'umd')
.pipe(rename('dotdotdot.umd.js'))
.pipe(gulp.dest('dist'));
};
exports.default = gulp.parallel(js, jsES6, jsESM, jsUMD);
// Watch task 'gulp watch': Starts a watch on JS tasks
const watch = cb => {
gulp.watch('src/*.ts', gulp.parallel(js, jsES6, jsUMD));
cb();
};
exports.watch = watch;