Skip to content

Commit ff9954d

Browse files
authored
Merge pull request #7 from esuarezz/master
Gulp file watching server files and adding default( I noticed the wat…
2 parents 2d94859 + 43f7961 commit ff9954d

File tree

2 files changed

+46
-20
lines changed

2 files changed

+46
-20
lines changed

README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,9 +57,12 @@ angular2-MEAN
5757
│ │ ├── app.component.css
5858
│ │ ├── app.component.ts
5959
│ │ ├── app.html
60+
│ │ ├── app.module.ts
61+
│ │ ├── app.routing.ts
6062
│ │ ├── main.ts
6163
│ ├── typings
6264
│ ├── index.html
65+
│ │ ├── systemjs.config.js
6366
│ ├── tsconfig.json
6467
│ ├── typings.json
6568
├── server

gulpfile.ts

Lines changed: 43 additions & 20 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.
@@ -89,17 +89,6 @@ gulp.task("libs", () => {
8989
.pipe(gulp.dest("dist/client/libs"));
9090
});
9191

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

10493
/**
10594
* Install typings for server and client.
@@ -135,3 +124,37 @@ gulp.task('start', function () {
135124
gulp.task("build", function (callback) {
136125
runSequence('clean', 'build:server', 'build:client', 'clientResources', 'libs', callback);
137126
});
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)