Deploying the example React App to Heroku is performed using Git commands. After setting up on Heroku, you add Heroku as a remote in your git config.
[code lang=text]
$ git remote add heroku git@heroku.com:your-heroku-app-name.git
[/code]
Git requires an SSH Key for secure communication with Heroku (see my article on Setup MacBook for node development). Deployment is then a push command. When Heroku receives the Git push command, it installs the application.
[code lang=text]
$ git push heroku master
[/code]
After the website has installed, Heroku will run the postInstall command in the package.json file, which in our case will perform a Webpack production build to output minified assets.
[code lang=text]
"dist": "webpack -p",
"postinstall": "npm run dist",
[/code]
Deployment to Heroku closes the loop in our JavaScript build pipeline and demonstrates how our foundation tools (Git, node.js) are leveraged by the Heroku cloud platform to provide a production environment for our application.
See the example React App running on Heroku.
Leave a Reply