Deploy to Heroku
Last updated
Last updated
Time to show the world what you have have built! To execute this, you can push the project to Heroku in order to showcase a live demo. Once complete you can share your demo with the world.
Initialize git on your project:
Create a and install the tool. Then run the following command on the root of your:
Heroku will attempt to install needless dependencies in your current project. Run this Heroku command and they will not be installed:
We need a server that Heroku would run to serve our static app. Install express and serve-static:
Next, create a server.js
file at the root of your project and add the following:
The code serves a dist
folder in our project. This folder does not exist unless we run the following command to build:
The command generates a build version of our app and puts the build in the dist
folder.
You can test the build by running:
Remove
dist/
from.gitnore
in the project root. This makes sure the Heroku does not ignore the directory since Heroku works with Git.
Heroku by default, would want to run the start
script in your package.json
. Let's set that up:
To deploy, first commit your changes to Git:
The run the following command to push to Heroku:
After the deploy process, run the command below to open the app: