-
Notifications
You must be signed in to change notification settings - Fork 1.4k
/
Copy pathbuild.js.prod.aot.ts
40 lines (34 loc) · 1.25 KB
/
build.js.prod.aot.ts
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
import { readdirSync, lstatSync } from 'fs';
import * as gulp from 'gulp';
import * as gulpLoadPlugins from 'gulp-load-plugins';
import { join } from 'path';
import Config from '../../config';
import { makeTsProject, TemplateLocalsBuilder } from '../../utils';
const plugins = <any>gulpLoadPlugins();
/**
* Executes the build process, transpiling the TypeScript files for the production environment.
*/
export = () => {
let tsProject = makeTsProject({}, Config.TMP_DIR);
let toIgnore = readdirSync(Config.TMP_DIR).filter((f: string) =>
lstatSync(join(Config.TMP_DIR, f)).isDirectory() && f !== Config.BOOTSTRAP_DIR)
.map((f: string) => '!' + join(Config.TMP_DIR, f, Config.NG_FACTORY_FILE + '.ts'));
let src = [
Config.TOOLS_DIR + '/manual_typings/**/*.d.ts',
join(Config.TMP_DIR, '**/*.ts'),
join(Config.TMP_DIR, `${Config.BOOTSTRAP_FACTORY_PROD_MODULE}.ts`),
...toIgnore
];
let result = gulp.src(src)
.pipe(plugins.plumber())
.pipe(tsProject())
.once('error', function(e: any) {
this.once('finish', () => process.exit(1));
});
return result.js
.pipe(plugins.template(new TemplateLocalsBuilder().build()))
.pipe(gulp.dest(Config.TMP_DIR))
.on('error', (e: any) => {
console.log(e);
});
};