|
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. |
@@ -89,17 +89,6 @@ gulp.task("libs", () => { |
89 | 89 | .pipe(gulp.dest("dist/client/libs")); |
90 | 90 | }); |
91 | 91 |
|
92 | | -/** |
93 | | - * Watch for changes in TypeScript, HTML and CSS files. |
94 | | - */ |
95 | | -gulp.task('watch', function () { |
96 | | - gulp.watch(["client/**/*.ts"], ['compile']).on('change', function (e) { |
97 | | - console.log('TypeScript file ' + e.path + ' has been changed. Compiling.'); |
98 | | - }); |
99 | | - gulp.watch(["client/**/*.html", "client/**/*.css"], ['clientResources']).on('change', function (e) { |
100 | | - console.log('Resource file ' + e.path + ' has been changed. Updating.'); |
101 | | - }); |
102 | | -}); |
103 | 92 |
|
104 | 93 | /** |
105 | 94 | * Install typings for server and client. |
@@ -135,3 +124,37 @@ gulp.task('start', function () { |
135 | 124 | gulp.task("build", function (callback) { |
136 | 125 | runSequence('clean', 'build:server', 'build:client', 'clientResources', 'libs', callback); |
137 | 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