Lab 22: Build & Deploy
Objectives
- Build a React Application
- Deploy the application to a web server
Steps
Build a React Application
- Open a command prompt(Windows) orterminal(Mac).
- Change the current directory to working\keeptrack.
- Run the following command to install the node.js web server named serve:npm install -g serve
- Run one of the following commands:npmnpm run buildYarnyarn build
- After the buld finishes, verify a keeptrack\builddirectory was created.
Deploy the application to a web server
- In the - command prompt(Windows) or- terminal(Mac) run the following command to start a web server and serve up the contents of the- builddirectory created in the last step.serve build- Assuming you would like to serve a state site, single page application or just a static file (no matter if on your device or on the local network), the package - serveis a web server that serves static content.- It behaves exactly like static deployments on https://vercel.com so it's perfect for developing your static project. - For more information see: https://www.npmjs.com/package/serve 
- The output should be as follows. Serving!...Copied local address to clipboard!
- Open a new browser tab and paste the local link copied to the clipboard in the last step into the address bar. 
- You should see the application running in your browser. 
- Click on Projects in the navigation menu on the top of the page and the list of projects should be displayed. - If you see the following error message displayed your backend is likely shut down. Run the command - npm run apito restart the backend. 
- After navigating to the projects route, refresh your browser. 
- You should see a 404 error page. 
- Use - Ctrl+Cto stop the web server.
- Start the web server again but add the - -sflag for single-page-application.serve -s build
- Follow these steps to verify the server is now redirecting to - index.htmlwhen it can't find a route.- Visit the root of the site http://localhost:5000/
- Click on Projects in the navigation menu on the top of the page and the list of projects should be displayed.
- After navigating to the projects route, refresh your browser.
- You should see the projects page refresh and display the projects.Note that you are no longer getting the 404 error page. 
 
- Visit the root of the site 
✔ You have completed Lab 22
If time permits you can read the documentation linked below for very similar steps to deploy the application on common production web servers and cloud platforms including AWS, Azure, Heroku, Netlify, and Vercel.