|
6 | 6 | "use strict"; |
7 | 7 |
|
8 | 8 | const gulp = require("gulp"), |
9 | | - del = require("del"), |
10 | | - tsc = require("gulp-typescript"), |
11 | | - sourcemaps = require('gulp-sourcemaps'), |
12 | | - tsProject = tsc.createProject("tsconfig.json"), |
13 | | - tslint = require('gulp-tslint'), |
14 | | - concat = require('gulp-concat'), |
15 | | - runSequence = require('run-sequence'), |
16 | | - nodemon = require('gulp-nodemon'), |
17 | | - gulpTypings = require("gulp-typings"); |
| 9 | + del = require("del"), |
| 10 | + tsc = require("gulp-typescript"), |
| 11 | + sourcemaps = require('gulp-sourcemaps'), |
| 12 | + tsProject = tsc.createProject("tsconfig.json"), |
| 13 | + tslint = require('gulp-tslint'), |
| 14 | + concat = require('gulp-concat'), |
| 15 | + runSequence = require('run-sequence'), |
| 16 | + nodemon = require('gulp-nodemon'), |
| 17 | + gulpTypings = require("gulp-typings"); |
18 | 18 |
|
19 | 19 | /** |
20 | 20 | * Remove build directory. |
@@ -81,27 +81,14 @@ gulp.task("clientResources", () => { |
81 | 81 | */ |
82 | 82 | gulp.task("libs", () => { |
83 | 83 | return gulp.src([ |
84 | | - 'angular2/bundles/angular2-polyfills.js', |
85 | | - 'systemjs/dist/system.src.js', |
86 | | - 'rxjs/bundles/Rx.js', |
87 | | - 'angular2/bundles/angular2.dev.js', |
88 | | - 'angular2/bundles/router.dev.js', |
89 | | - 'angular2/bundles/http.dev.js', |
| 84 | + 'core-js/client/shim.min.js', |
| 85 | + 'zone.js/dist/zone.js', |
| 86 | + 'reflect-metadata/Reflect.js', |
| 87 | + 'systemjs/dist/system.src.js' |
90 | 88 | ], {cwd: "node_modules/**"}) /* Glob required here. */ |
91 | 89 | .pipe(gulp.dest("dist/client/libs")); |
92 | 90 | }); |
93 | 91 |
|
94 | | -/** |
95 | | - * Watch for changes in TypeScript, HTML and CSS files. |
96 | | - */ |
97 | | -gulp.task('watch', function () { |
98 | | - gulp.watch(["client/**/*.ts"], ['compile']).on('change', function (e) { |
99 | | - console.log('TypeScript file ' + e.path + ' has been changed. Compiling.'); |
100 | | - }); |
101 | | - gulp.watch(["client/**/*.html", "client/**/*.css"], ['clientResources']).on('change', function (e) { |
102 | | - console.log('Resource file ' + e.path + ' has been changed. Updating.'); |
103 | | - }); |
104 | | -}); |
105 | 92 |
|
106 | 93 | /** |
107 | 94 | * Install typings for server and client. |
@@ -137,3 +124,37 @@ gulp.task('start', function () { |
137 | 124 | gulp.task("build", function (callback) { |
138 | 125 | runSequence('clean', 'build:server', 'build:client', 'clientResources', 'libs', callback); |
139 | 126 | }); |
| 127 | + |
| 128 | +/** |
| 129 | + * Watch for changes in TypeScript, HTML and CSS files. |
| 130 | + */ |
| 131 | +gulp.task('watch', function () { |
| 132 | + gulp.watch(["client/**/*.ts"], ['compile']).on('change', function (e) { |
| 133 | + console.log('TypeScript file ' + e.path + ' has been changed. Compiling.'); |
| 134 | + }); |
| 135 | + gulp.watch(["client/**/*.html", "client/**/*.css"], ['clientResources']).on('change', function (e) { |
| 136 | + console.log('Resource file ' + e.path + ' has been changed. Updating.'); |
| 137 | + }); |
| 138 | + gulp.watch(["server/src/**/*.ts"], ['compile']).on('change', function (e) { |
| 139 | + console.log('TypeScript file ' + e.path + ' has been changed. Compiling.'); |
| 140 | + }); |
| 141 | +}); |
| 142 | + |
| 143 | +/** |
| 144 | + * Build the project. |
| 145 | + * 1. Clean the build directory |
| 146 | + * 2. Build Express server |
| 147 | + * 3. Build the Angular app |
| 148 | + * 4. Copy the resources |
| 149 | + * 5. Copy the dependencies. |
| 150 | + */ |
| 151 | + |
| 152 | +gulp.task("build", function (callback) { |
| 153 | + runSequence('clean', 'build:server', 'build:client', 'clientResources', 'libs', callback); |
| 154 | +}); |
| 155 | + |
| 156 | + |
| 157 | +gulp.task('default', function() { |
| 158 | + runSequence( 'build:server', 'build:client', 'clientResources', 'libs','watch','start'); |
| 159 | + |
| 160 | +}); |
0 commit comments