1npm install -g create-react-app
2create-react-app my-app
3cd my-app
4git init
5heroku create -b https://github.com/mars/create-react-app-buildpack.git
6git add .
7git commit -m "react-create-app on Heroku"
8git push heroku master
9heroku open
10
1"scripts": {
2 "dev": "react-scripts
3 "start", "start": "serve -s build",
4 "build": "react-scripts build",
5 "test": "react-scripts test --env=jsdom",
6 "eject": "react-scripts eject",
7 "heroku-postbuild": "npm run build"
8},
9
1const path = require('path');const express = require('express');const app = express();const publicPath = path.join(__dirname, '..', 'public');const port = process.env.PORT || 3000;app.use(express.static(publicPath));app.get('*', (req, res) => { res.sendFile(path.join(publicPath, 'index.html'));});app.listen(port, () => { console.log('Server is up!');});