Skip to content

Instantly share code, notes, and snippets.

@spac3unit
Forked from mars/create-react-app-on-heroku.sh
Created September 8, 2017 16:31
Show Gist options
  • Select an option

  • Save spac3unit/7a4f2851cbf5a40c090f4accbedf373a to your computer and use it in GitHub Desktop.

Select an option

Save spac3unit/7a4f2851cbf5a40c090f4accbedf373a to your computer and use it in GitHub Desktop.
Create a React app & deploy to Heroku
## Global install of the app generator
npm install -g create-react-app
## Setup the app (first-time only)
create-react-app my-app
cd my-app
git init
# Create the Heroku app; requires free account at https://www.heroku.com/
heroku create -b https://github.com/heroku/heroku-buildpack-static.git
# Set the web root to the build/ directory
echo '{ "root": "build/" }' > static.json
# Allow JS bundle to be committed (removes `build` from ignores)
sed '/build/d' .gitignore > .gitignore.new && mv .gitignore.new .gitignore
## Build, commit, & deploy
npm run build
git add .
git commit -m "react-create-app on Heroku"
git push heroku master
## Visit the live React app in your browser
heroku open
# Develop your app locally using `npm start`
# Then build, commit, & deploy ♻️
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment