This repository was archived by the owner on Oct 12, 2021. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 172
Expand file tree
/
Copy pathgulpfile.ts
More file actions
119 lines (105 loc) · 2.7 KB
/
gulpfile.ts
File metadata and controls
119 lines (105 loc) · 2.7 KB
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
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
const childProcess = require('child_process');
const commonjs = require('rollup-plugin-commonjs');
const gulp = require('gulp');
const jsmn = require('gulp-jasmine');
const rimraf = require('rimraf');
const rollup = require('rollup');
const nodeResolve = require('rollup-plugin-node-resolve');
const runSequence = require('run-sequence');
const change = require('gulp-change');
gulp.task('clean', done => {
rimraf('./tmp', () => {
rimraf('./dist', done);
});
});
gulp.task('build', done => runSequence(
'clean',
'task:build',
'task:deploy',
done));
gulp.task('test', done => runSequence(
'clean',
'task:test',
done));
gulp.task('task:build', done => runSequence(
'task:app:compile_esm',
'task:app:bundle',
done));
gulp.task('task:test', done => runSequence(
'task:app:compile_es5',
'task:app:test',
done))
gulp.task('task:deploy', done => runSequence(
[
'task:app:deploy',
'task:bundles:deploy',
'task:package:deploy',
],
done));
gulp.task('task:app:compile_es5', () => {
childProcess.execSync('node_modules/.bin/tsc -p tsconfig.es5.json');
});
gulp.task('task:app:compile_esm', () => {
childProcess.execSync('node_modules/.bin/ngc -p tsconfig.esm.json');
});
gulp.task('task:app:bundle', done => rollup
.rollup({
entry: 'tmp/esm/src/index.js',
plugins: [
nodeResolve({jsnext: true, main: true}),
commonjs({
include: 'node_modules/**',
}),
],
external: [
'@angular/core',
]
})
.then(bundle => bundle.write({
format: 'umd',
moduleName: 'ng.appShell',
dest: 'tmp/es5/bundles/app-shell.umd.js',
globals: {
'@angular/core': 'ng.core',
},
})));
gulp.task('task:app:deploy', () => gulp
.src([
'tmp/esm/src/index.d.ts',
'tmp/esm/src/index.js',
'tmp/esm/src/index.js.map',
'tmp/esm/src/index.metadata.json',
'tmp/esm/src/app/**/*.d.ts',
'tmp/esm/src/app/**/*.js',
'tmp/esm/src/app/**/*.js.map',
'tmp/esm/src/app/**/*.metadata.json',
], {base: 'tmp/esm/src'})
.pipe(gulp.dest('dist')));
gulp.task('task:app:test', () => gulp
.src([
'tmp/es5/src/unit_tests.js',
], {base: '.'})
.pipe(jsmn({
verbose: true,
})));
gulp.task('task:bundles:deploy', () => gulp
.src([
'tmp/es5/bundles/**/*.js',
'tmp/es5/bundles/**/*.js.map',
], {base: 'tmp/es5'})
.pipe(gulp.dest('dist')));
const updatePackage = (content: string) => {
const blacklist = [
'private',
'devDependencies'
];
const parsed = JSON.parse(content);
blacklist.forEach(prop => delete parsed[prop]);
return JSON.stringify(parsed, null, 2);
};
gulp.task('task:package:deploy', () => gulp
.src([
'package.json'
])
.pipe(change(updatePackage))
.pipe(gulp.dest('dist')));