Building and Deploying Angular Applications
Local Development
You may wish to test your app locally. Assume your Angular app is named your-angular-app
. Therefore, the folder containing your app is named your-angular-app
. This is your project root directory.
- Go to your Angular app directory, using a terminal
cd your-angular-app
- Start the development server, using the following command
ng serve
This command will compiles and builds all files, and then starts the server.
- To access the app, open a web browser, enter a URL
http://localhost:4200
Note: Node.js server runs on port 4200, by default.
- To shutdown the server, go to the terminal where
ng serve
is running, and press keyboardCtrl+c
Server Deployment
To deploy, you should build your app for production.
- Go to your Angular app directory, using a terminal
cd your-angular-app
- Run the following command to make your app production ready
ng build
This will create a
dist
folder in your project root directory. Thedist
folder contains ayour-angular-app
folder; theyour-angular-app
folder should basically contain the following files3rdpartylicenses.txt es2015-polyfills.1e04665e16f944715fd2.js favicon.ico index.html main.39049915a67858ea8ac0.js polyfills.8bbb231b43165d65d357.js runtime.26209474bfa8dc87a77c.js styles.3ff695c00d717f2d2a11.css
- Upload those files to the server in the directory you choose.
- Optional: If you get errors, you may need to update the
<base>
in index.html depending on the server config. For our cs4640 server, update this to:<base href=".">