-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgulpfile.js
157 lines (138 loc) · 4.04 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
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
'use strict';
var gulp = require('gulp'),
server = require('gulp-server-livereload'),
rename = require('gulp-rename'),
intercept = require('gulp-intercept'),
systemjsbuilder = require("systemjs-builder");
// >>> GULP TASK to run app's standalone web server for JIT app
gulp.task('serve', function() {
var webroot = '.';
var webfolders = [webroot];
gulp.src(webfolders)
.pipe(server({
host: 'localhost',
port: '8080',
defaultFile: 'index.html',
fallback: 'index.html',
livereload: false,
directoryListing: false,
open: false
}));
});
// <<< GULP TASK to run app's standalone web server for JIT app
// >>> GULP TASK to run app's standalone web server for AOT app
gulp.task('serve:aot', function() {
var webroot = '.';
var webfolders = [webroot];
gulp.src(webfolders)
.pipe(server({
host: 'localhost',
port: '8081',
defaultFile: 'index.aot.html',
fallback: 'index.aot.html',
livereload: false,
directoryListing: false,
open: false
}));
});
// <<< GULP TASK to run app's standalone web server for AOT app
// >>> GULP TASK to run app's bundled standalone web server for AOT app
gulp.task('serve:bundles', function() {
var webroot = '.';
var webfolders = [webroot];
gulp.src(webfolders)
.pipe(server({
host: 'localhost',
port: '8082',
defaultFile: 'index.bundles.html',
fallback: 'index.bundles.html',
livereload: false,
directoryListing: false,
open: false
}));
});
// <<< GULP TASK to run app's bundled standalone web server for AOT app
// >>> GULP TASK to create the RxJS re-bundle
gulp.task('rxjs', function() {
// SystemJS build options
var options = {
normalize: true,
runtime: false,
sourceMaps: false,
sourceMapContents: false,
minify: true,
mangle: true
};
var builder = new systemjsbuilder('./');
builder.config({
paths: {
"n:*": "node_modules/*",
"rxjs/*": "node_modules/rxjs/*.js",
},
map: {
"rxjs": "n:rxjs",
},
packages: {
"rxjs": {main: "Rx.js", defaultExtension: "js"},
}
});
builder.bundle('rxjs', 'assets/rxjs-bundle/Rx.min.js', options);
});
// <<< GULP TASK to create the RxJS re-bundle
// >>> GULP TASK to eliminate decorators from packages' JS for pure AOT app
gulp.task('removing-decorators-from-packages', function() {
var packagesRoot = './node_modules';
var paths = {
jsSource: [
packagesRoot + '/**/angular-modal-gallery/bundles/angular-modal-gallery.umd.js'
],
jsOutput: packagesRoot
};
return gulp.src(paths.jsSource)
.pipe(intercept(function(file) {
var decoratorsRegex = /(.*\.decorators\s{0,}=\s{0,}\[[\s\S]*?\]\s{0,};\s{0,}(\r\n|\n))/gm;
var codeSource = file.contents.toString();
file.contents = new Buffer(codeSource.replace(/(.*\.decorators\s{0,}=\s{0,}\[[\s\S]*?\]\s{0,};\s{0,}(\r\n|\n))/gm, ''));
return file;
}))
.pipe(rename(function (path) {
var parts = path.basename.split('.');
var baseBundleName = parts[0];
baseBundleName = baseBundleName + '.' + 'aot';
parts[0] = baseBundleName;
path.basename = parts.join('.');
}))
.pipe(gulp.dest(paths.jsOutput));
});
// <<< GULP TASK to eliminate decorators from packages' JS for pure AOT app
// >>> GULP TASK to create app's JS bundles with AOT
gulp.task('bundles:aot', function() {
var options = {
normalize: true,
runtime: false,
sourceMaps: false,
sourceMapContents: false,
minify: true,
mangle: true,
format: 'cjs'
};
var builder = new systemjsbuilder('.');
builder.bundle(
'[app/**/*.js] - [app/boot.js] - [app/boot.parcel.js] - [app/boot.parcel.aot.js] - [app/systemjs.config.js]',
'app-bundles/app.bundle.aot.min.js',
options
);
builder.bundle(
'[node_modules/primeng/components/dom/domhandler.js] + ' +
'[node_modules/primeng/components/slider/*.js]',
'app-bundles/packages/primeng.bundle.aot.min.js',
options
);
builder.bundle(
'[node_modules/angular-modal-gallery/bundles/angular-modal-gallery.aot.umd.js] + ' +
'[node_modules/angular-modal-gallery/angular-modal-gallery.ngfactory.js]',
'app-bundles/packages/angular-modal-gallery.bundle.aot.min.js',
options
);
});
// <<< GULP TASK to create app's JS bundles with AOT