forked from johnpapa/angular-tour-of-heroes
-
Notifications
You must be signed in to change notification settings - Fork 0
/
gulpfile.js
75 lines (64 loc) · 1.61 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
var gulp = require('gulp');
var del = require('del');
var $ = require('gulp-load-plugins')({ lazy: true });
var lite = require('lite-server');
var config = {
build: './dist/build.js',
plugins: [
'node_modules/core-js/client/shim.min.js',
'node_modules/zone.js/dist/zone.js'
],
index: {
run: 'index.html',
aot: 'index-aot.html',
aotgz: 'index-aot-gzip.html',
jit: 'index-jit.html'
},
dest: './dist',
root: './'
};
gulp.task('help', $.taskListing);
gulp.task('default', ['help']);
gulp.task('gzip', function () {
log('gzipping');
var source = [].concat(config.plugins, config.build);
return gulp.src(source)
.pipe($.gzip())
.pipe(gulp.dest(config.dest));
});
gulp.task('copy-aot-gzip', ['gzip', 'clean'], function () {
log('copy aot gzip');
return copyIndex(config.index.aotgz);
});
gulp.task('copy-aot', ['clean'], function () {
log('copy aot');
return copyIndex(config.index.aot);
});
function copyIndex(source) {
return gulp.src(source)
.pipe($.rename(config.index.run))
.pipe(gulp.dest(config.root));
}
gulp.task('copy-jit', ['clean'], function () {
log('copy jit');
return copyIndex(config.index.jit);
});
gulp.task('clean', function (done) {
log('clean');
del([config.index.run]).then(paths => {
// console.log('Deleted files and folders:\n', paths.join('\n'));
done()
});
});
function log(msg) {
if (typeof (msg) === 'object') {
for (var item in msg) {
if (msg.hasOwnProperty(item)) {
$.util.log($.util.colors.blue(msg[item]));
}
}
} else {
$.util.log($.util.colors.blue(msg));
}
}
module.exports = gulp;