Skip to main content Link Menu Expand (external link) Document Search Copy Copied

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.

  1. Go to your Angular app directory, using a terminal
     cd your-angular-app
    
  2. Start the development server, using the following command
     ng serve
    

    This command will compiles and builds all files, and then starts the server.

  3. To access the app, open a web browser, enter a URL
     http://localhost:4200
    

    Note: Node.js server runs on port 4200, by default.

  4. To shutdown the server, go to the terminal where ng serve is running, and press keyboard Ctrl+c

Server Deployment

To deploy, you should build your app for production.

  1. Go to your Angular app directory, using a terminal
     cd your-angular-app
    
  2. Run the following command to make your app production ready
     ng build
    

    This will create a dist folder in your project root directory. The dist folder contains a your-angular-app folder; the your-angular-app folder should basically contain the following files

     3rdpartylicenses.txt
     es2015-polyfills.1e04665e16f944715fd2.js
     favicon.ico
     index.html
     main.39049915a67858ea8ac0.js
     polyfills.8bbb231b43165d65d357.js
     runtime.26209474bfa8dc87a77c.js
     styles.3ff695c00d717f2d2a11.css
    
  3. Upload those files to the server in the directory you choose.
  4. 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=".">