-
Notifications
You must be signed in to change notification settings - Fork 2
/
gulpfile.js
116 lines (76 loc) · 2.65 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
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
'use strict';
const Path = require('path');
const gulp = require('gulp');
const rename = require('gulp-rename');
const inlineNg2Template = require('gulp-inline-ng2-template');
const ts = require('gulp-typescript');
const clean = require('gulp-clean');
const Builder = require('systemjs-builder');
const DISTGULP = './dist-gulp';
const TMP = './tmp-gulp/app';
const SRC = './src/app/**/*.ts';
const TMPSRC = Path.join(TMP, SRC);
const options = {
base: 'src/app',
target: 'es5',
useRelativePaths: true
};
const tsProject = ts.createProject('./src/tsconfig.json', {
noExternalResolve: true
});
gulp.task('copy-vendor-tmp', function () {
return gulp.src('./dist/vendor/**/*').pipe(gulp.dest('./tmp-gulp/vendor'))
});
gulp.task('copy-base-dist', function () {
return gulp.src('./dist/*').pipe(gulp.dest('./tmp-gulp'));
});
gulp.task('copy-base-folder', ['copy-base-dist'], function () {
return gulp.src(
['tmp-gulp/favicon.ico',
'tmp-gulp/preloader.css',
'tmp-gulp/icon.png',
'CNAME'])
.pipe(gulp.dest('./dist-gulp'));
});
gulp.task('reflect-metadata', ['copy-vendor-tmp'], function () {
return gulp.src('./tmp-gulp/vendor/reflect-metadata/Reflect.js')
.pipe(gulp.dest('./dist-gulp/vendor/reflect-metadata'));
});
gulp.task('zone.js', ['copy-vendor-tmp'], function () {
return gulp.src('./tmp-gulp/vendor/zone.js/dist/zone.js')
.pipe(gulp.dest('./dist-gulp/vendor/zone.js/dist'));
});
gulp.task('copy-vendor-dist', ['reflect-metadata', 'zone.js'], function () {
//
});
gulp.task('copy-cname', function () {
return gulp.src('CNAME').pipe(gulp.dest('./dist-gulp'));
});
gulp.task('copy-index', function () {
return gulp.src('./src/index.prod.html')
.pipe(rename({
basename: 'index'
}))
.pipe(gulp.dest('./dist-gulp'));
})
gulp.task('pre:build', [
'copy-base-folder',
'copy-vendor-dist',
'copy-cname',
'copy-index'
], function () {
return gulp.src('./dist/app/**/*.js')
.pipe(inlineNg2Template(options))
.pipe(gulp.dest(TMP))
});
gulp.task('clean', function () {
return gulp.src([DISTGULP, 'tmp-gulp']).pipe(clean());
});
gulp.task('build', ['clean', 'pre:build'], function () {
const builder = new Builder('./tmp-gulp', './tmp-gulp/system-config.js');
builder.buildStatic('main.js', 'dist-gulp/build.js',{
minify: true,
sourceMaps: true,
mangle: false
});
});