Skip to content

Commit 43f7961

Browse files
committed
Gulp file watching server files and adding default( I noticed the watching was getting crazy many times if it is not written with this "flow"
Readme update with Angular2-RC5 structure
1 parent 2cd336d commit 43f7961

File tree

2 files changed

+60
-30
lines changed

2 files changed

+60
-30
lines changed

README.md

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
## [ Angular2 Updated to RC5 ]
12
# Angular2 MEAN - QuickStart application with ExpressJS, MongoDB, Gulp and Typescript (Repository Pattern)
23

34
[![Build status](https://ci.appveyor.com/api/projects/status/y7cp312hef8sju0w/branch/master?svg=true)](https://ci.appveyor.com/project/moizKachwala/angular2-express-mongo-gulp-node-typescript/branch/master)
@@ -18,9 +19,15 @@ It also uses Gulp for running task and TsLint.The seed application is built over
1819

1920
## Steps to Run
2021
```sh
21-
npm install <= install all the npm Dependencies
22-
npm build <= build client and server application.
23-
npm start <= start the Nodemon and watch for changes.
22+
npm install <= install all the npm Dependencies
23+
npm run build <= build client and server application.
24+
npm run start <= start the Nodemon and watch for changes.
25+
```
26+
27+
## Global packages
28+
```
29+
npm install ts-node -g
30+
npm install typescript-node -g
2431
```
2532

2633
## Directory Structure
@@ -50,9 +57,12 @@ angular2-MEAN
5057
│ │ ├── app.component.css
5158
│ │ ├── app.component.ts
5259
│ │ ├── app.html
60+
│ │ ├── app.module.ts
61+
│ │ ├── app.routing.ts
5362
│ │ ├── main.ts
5463
│ ├── typings
5564
│ ├── index.html
65+
│ │ ├── systemjs.config.js
5666
│ ├── tsconfig.json
5767
│ ├── typings.json
5868
├── server
@@ -142,4 +152,3 @@ angular2-MEAN
142152
## License
143153

144154
MIT
145-

gulpfile.ts

Lines changed: 47 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -6,15 +6,15 @@
66
"use strict";
77

88
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");
1818

1919
/**
2020
* Remove build directory.
@@ -81,27 +81,14 @@ gulp.task("clientResources", () => {
8181
*/
8282
gulp.task("libs", () => {
8383
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'
9088
], {cwd: "node_modules/**"}) /* Glob required here. */
9189
.pipe(gulp.dest("dist/client/libs"));
9290
});
9391

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-
});
10592

10693
/**
10794
* Install typings for server and client.
@@ -137,3 +124,37 @@ gulp.task('start', function () {
137124
gulp.task("build", function (callback) {
138125
runSequence('clean', 'build:server', 'build:client', 'clientResources', 'libs', callback);
139126
});
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

Comments
 (0)