I am trying to get my angular 2 + express app to reload itself when either the express code changes or the angular 2 app changes. My understanding is that I need to run ng build, then have express serve up the index.html file that is located in the dist/ folder.
ng serve is probably the only way to auto-reload, but I'm hoping for a 3rd party app or an option to ng build that would make it rebuild when the angular 2 code changes.
The best I can do right now is ng serve and just test the angular part. Or making an npm build script that looks like ng build && nodemon server.js which will build angular 2, and auto reload if the express code changes (but not the angular 2 code).
Thanks for any tips on how to get this done, I'm very new to angular 2.
Ubuntu
angular-cli: 1.0.0-beta.28.3
node: 7.2.0
os: linux x64
@angular/common: 2.4.5
@angular/compiler: 2.4.5
@angular/core: 2.4.5
@angular/forms: 2.4.5
@angular/http: 2.4.5
@angular/platform-browser: 2.4.5
@angular/platform-browser-dynamic: 2.4.5
@angular/router: 3.4.5
@angular/compiler-cli: 2.4.5
ng build
ng build --watch will output in dist/ and watch for changes, then rebuild.
ng serve takes an option for passing a proxy for a backend (like express) that it will serve locally.
Closing this.
because of the way our project is structured (old parts of the app in PHP) we have to use ng build --watch instad of ng serve. The routing is handled by php until we can fully "angular-ize" the app. Is there a way to integrate livereload or browsersync with ng build --watch so that once it rebuilds it will reload the browser window with it?
A clearer explanation of the closing comment:
https://medium.com/@danielkagan/serve-mean-stack-using-angular-cli-f39b33dbad64
This issue has been automatically locked due to inactivity.
Please file a new issue if you are encountering a similar or related problem.
Read more about our automatic conversation locking policy.
_This action has been performed automatically by a bot._
Most helpful comment
ng build --watchwill output indist/and watch for changes, then rebuild.ng servetakes an option for passing a proxy for a backend (like express) that it will serve locally.Closing this.