Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

docs(deployment): add deployment instructions for Heroku #3889

Closed
wants to merge 2 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
45 changes: 44 additions & 1 deletion docs/guide/deployment.md
Expand Up @@ -261,7 +261,50 @@ npm install -g now

### Heroku

> TODO | Open to contribution.
To deploy with [Heroku](https://heroku.com/), we will use the official [Node.js buildpack](https://github.com/heroku/heroku-buildpack-nodejs). Heroku will automatically use this buildpack when it sees the `package.json` file in the root of your project.

We will also use [Express](https://expressjs.com/) to serve the static (dist) files to the Heroku load balancer.


1. Install and add Express to your dependencies

```bash
npm install express --save
```

2. Create a `server.js` file in the root of your project.

```js
const port = process.env.PORT || 3000

let express = require('express'),
path = require('path'),
app = express()

app.use(express.static(path.resolve(__dirname, 'dist')))

app.get('*', (req, res) => {
res.sendFile(path.resolve(__dirname, 'dist', 'index.html'))
})

app.listen(port);
```

3. In your `package.json` file, add a `start` script.

```json
{
...
"scripts": {
"start": "node server.js"
}
...
}
```

4. Push your code to your Heroku Git repository.

5. You may also push your code to your Github repository and link it your Heroku app to deploy from there. Just go to the **Deploy** tab of your Heroku app, and choose **Github** in the deployment method.

### Surge

Expand Down