Im making a MEAN stack application with Angular 4.
What I've done:
- Created a MVC directory structure for my Node/Express App.
- Created a Node/Express server.
- Created a basic API which with express with a prefixed path of
/api - Tested the API using POSTMAN
- Used Angular-Cli to create a angular project within my root directory of the MEAN stack app.
- Within
.angular-cli.jsonchangedoutDirproperty to../public - Changed my Server file to send Send all other requests (that are not going to
/api) to the Angular app
My Directory Structure:
- angular-src folder contains the angular app generated by
angular-cli - app-api folder contains my API which performs all CRUD operations. This is where all the
/apiroutes are directed to. - app-server folder contains just a route file which sends all
/to the angular app (public/index.html) - public folder is where the angular app's
index.htmlfile lives after runningng build - app.js is where my node/express server lives and redirects incoming api requests
When I run the app it works. The node server sends my requests to the Angular Apps index.html with the public folder and that displays my app.component.html template.
My questions:
I run
nodemonto start my node/express server & then navigate toangular-srcfolder and runng buildto setup my angular app. This process seems quite lengthy to me whats a better way of achieving this?Also I have to run ng build every time I make changes to the angular app so it can read the changes. Is there anything like
nodemonbut for angular that watches for changes and resets automatically.I have 2
package.jsonfiles. Once for node/express and another for angular. Should there be only 1package.jsonfile within a project?The App finally has to be launched on Heroku currently I have a Procfile which contains
web: npm start. How do I manage angular 4 within heroku? Do I need to add ang buildcommand to the Procfile?Should the Angular App & Node/express run different ports (i.e port 3000 & 4200) or should both be on a single port?
Is the structure that I've implemented suitable for a MEAN App using Angular 4.
I know some of these questions might be opinion based but I'm looking for your professional advice as to whats considered best practice within these situations.

proxy.conf.jsonfile for port-forwarding and usenpm-run-allas described in this answer to have it run with a single command - stackoverflow.com/a/45743298/4365626