ReactPWA

ReactPWA

  • Docs
  • Features
  • Blog
  • Examples
  • Help

›Deployments

Getting Started

  • Initial setup
  • PawJS Configuration
  • Web App manifest

Guide

  • External resources
  • Internal APIs
  • Environment Variables

Routing

  • Add new route
  • Async routing
  • Nested routes

Plugins

  • Redux
  • Image Optimization
  • Sass
  • LESS

Deployments

  • Heroku
  • Amazon EC2
  • Digital Ocean
Edit

Deploying to Heroku

Prerequisites

  • Heroku Account
  • Heroku CLI
  • Git CLI

Step 1: Create a Procfile

Heroku apps include a Procfile that specifies the commands that are executed by the app’s dynos.

Add a new file named Procfile in the root of your project folder. The Procfile is always a simple text file that is named Procfile exactly. For example, Procfile.txt is not valid.

Procfile Content

A Procfile declares its process types on individual lines, each with the following format:

<process type>: <command>

The code for Procfile will be:

web: node dist/server.js

Step 2: Remove dist from .gitignore

Make sure that dist folder is not ignored in the .gitignore file. Else, comment it as shown below:

...
# dist
...

Step 3: Build the App.

Build the app using the following command:

$ npm run build

This will create a dist folder in the root directory of the project.

Step 4: Add dist & Procfile folder to repository

$ git add . // Add everything
// --- OR --- 
$ git add dist // Just the dist folder
$ git add Procfile // Just add the Procfile

$ git commit -m "Adding dist folder & Procfile to the repository" 

Step 5: Create Heroku Remote

The heroku create CLI command creates a new empty application on Heroku, along with an associated empty Git repository. If you run this command from your app’s root directory, the empty Heroku Git repository is automatically set as a remote for your local repository.

$ heroku create
Creating app... done, ⬢ thawing-inlet-61413
https://thawing-inlet-61413.herokuapp.com/ | https://git.heroku.com/thawing-inlet-61413.git

Add the remote named heroku to existing repository

$ git remote add heroku  https://git.heroku.com/thawing-inlet-61413.git

Step 6: Deploy the code

To deploy your app to Heroku, you typically use the git push command to push the code from your local repository’s master branch to your heroku remote.

$ git push heroku master
Initializing repository, done.
updating 'refs/heads/master'
...

Use this same command whenever you want to deploy the latest committed version of your code to Heroku.

Note: Make sure to build the app before committing and pushing the code to git. Heroku only deploys code that you push to the master branch of the heroku remote. Pushing code to another branch of the remote has no effect.

← LESSAmazon EC2 →
  • Prerequisites
  • Step 1: Create a Procfile
    • Procfile Content
  • Step 2: Remove dist from .gitignore
  • Step 3: Build the App.
  • Step 4: Add dist & Procfile folder to repository
  • Step 5: Create Heroku Remote
  • Step 6: Deploy the code
ReactPWA
Docs
Getting StartedPluginsExamples
Community
User ShowcaseProject Chat
More
BlogGitHubStar

Giants supporting us

Atyantik Technologies Private LimitedDigitalOceanEventerpriseBrowserStackNavicat
 
Support ReactPWA

Copyright © 2019 Atyantik Technologies Private Limited