-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathgulpfile.js
89 lines (77 loc) · 1.91 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
const babel = require("rollup-plugin-babel");
const commonjs = require('rollup-plugin-commonjs');
const del = require('del');
const gulp = require("gulp");
const rollup = require('rollup').rollup;
const uglify = require('rollup-plugin-uglify');
const buildTasks = [
"build:es2015",
"build:global",
"build:nodeEs5"
];
const babelConf = {
babelrc: false,
presets: ['es2015-rollup']
};
let es2015Cache, globalCache, nodeEs5Cache;
gulp.task('clean', function() {
return del(["./dist"]);
});
gulp.task('build:es2015', () => rollup({
cache: es2015Cache,
entry: './src/es2015.js',
}).then((bundle) => {
cache = bundle;
return bundle.write({
format: 'es',
dest: './dist/es2015-Promise.allSettled.js'
})
}));
gulp.task('build:global', () => rollup({
cache: es2015Cache,
entry: './src/es2015.js',
plugins: [
babel(babelConf)
]
}).then((bundle) => {
cache = bundle;
return bundle.write({
format: 'iife',
dest: './dist/es2015.Promise.allSettled.ponyfill.js'
})
}));
gulp.task('build:ngIdxUtils', () => rollup({
cache: ngIdxUtilsCache,
entry: './src/ng/ng-idx-utils.js',
external: [],
plugins: [
babel(babelConf),
uglify()
]
}).then((bundle) => {
cache = bundle;
return bundle.write({
format: 'iife',
dest: './assets/js/ng-idx-utils.min.js',
sourceMap: true
})
}));
gulp.task('build:nodeEs5', () => rollup({
cache: nodeEs5Cache,
entry: './src/es2015.js',
plugins: [
commonjs(),
babel(babelConf)
]
}).then((bundle) => {
cache = bundle;
return bundle.write({
format: 'cjs',
dest: './index.js'
})
}));
gulp.task("watch", function() {
return gulp.watch(['./src/**/*.*'], gulp.parallel(buildTasks));
});
gulp.task("build", gulp.series('clean', gulp.parallel(buildTasks)));
gulp.task("default", gulp.series('clean', gulp.parallel(buildTasks), 'watch'));