Deploy Production React App to Heroku
Deploying React App to Heroku can be a bit tricky, at least for me first time doing it ;). So I've decided to write a blog post to have a reference in future…
Deploying React App to Heroku can be a bit tricky, at least for me first time doing it ;). So I've decided to write a blog post to have a reference in future, hope it will help someone as it helped me.
What you need:
1) React app ready to deploy.
2) Make sure node is installed. In my case I specified Node version in package.json(It was required by Heroku CLI):
What you need:
1) React app ready to deploy.
2) Make sure node is installed. In my case I specified Node version in package.json(It was required by Heroku CLI):
"name": "bungie-api",
"version": "0.1.0",
"engines": {
"node": "10.13.0"
},3) Add server.js file in root folder of your project:
const express = require('express');
const favicon = require('express-favicon');
const path = require('path');
const port = process.env.PORT || 8080;
const app = express();
app.use(favicon(__dirname + '/build/favicon.ico'));app.use(express.static(__dirname));
app.use(express.static(path.join(__dirname, 'build')));
app.get('/ping', function (req, res) {
return res.send('pong');
});
app.get('/*', function (req, res) {
res.sendFile(path.join(__dirname, 'build', 'index.html'));
});app.listen(port);4) Install express-favicon
yarn add express express-favicon
5) Modify scripts in package.json
"scripts": {
"start": "node server.js",
"build": "react-scripts build",
"test": "react-scripts test",
"eject": "react-scripts eject"
},6) Create .env file in root directory. It will prevent react to build development code
GENERATE_SOURCEMAP=false
7) Now deploy to Heroku. In my case I just linked my dyno with github and pointed to master branch, so each time I push my code to master it will start automatically deploying to Heroku.
And to be more safe:
// keep reading

Indie Release Notes #6: MudQuest Reborn
MudQuest Reborn: Enhanced indie game with SwiftUI, new partnerships, and app updates for better performance
read→
Indie Updates: 413 Content Too Large
Struggling to scale down MudQuest project as deadline looms. Refocusing on real-time event finder. Key features outlined for completion
read→
Indie Release Notes #5
Discover MudQuest: the first social media app for off-road enthusiasts to organize and join real-time adventures and trail gatherings
read→