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

Add description on how to deploy with Heroku #3684

Closed
wants to merge 1 commit 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
49 changes: 48 additions & 1 deletion docs/guide/deployment.md
Expand Up @@ -261,7 +261,54 @@ npm install -g now

### Heroku

> TODO | Open to contribution.
To deploy with [Heroku](https://heroku.com/), you need to follow the following steps:
1. Make sure you have `git`, `npm` and `node` installed.
1. Create a free [Heroku account](https://signup.heroku.com/).
1. Download the [Heroku CLI](https://devcenter.heroku.com/articles/heroku-cli) and [login](https://devcenter.heroku.com/articles/heroku-cli#getting-started).
1. In your project repository, run:
```bash
$ heroku create
```
This will add a new remote called `heroku` to your Git remotes.
4. Install a static file server to your project, for example [Express](https://expressjs.com/):
```bash
$ npm i --save express serve-static
```
5. Configure Express with a `server.js` file:
```javascript
const express = require('express');
const serveStatic = require("serve-static")
const path = require('path');

const publicDir = path.resolve(__dirname, "dist");

// Serve static files in dist/
app = express();
app.use(serveStatic(publicDir));

// When using vue-router in history mode, redirect all other routes to index.html
app.get("*", (req, res) => {
res.sendFile(path.resolve(publicDir, "index.html"))
})

const port = process.env.PORT || 80;
app.listen(port);
```
6. Add a start script in `package.json`:
```json
...
"scripts": {
"serve": "vue-cli-service serve",
"build": "vue-cli-service build",
"start": "node server.js" // This script will be invoked by Heroku automatically
},
...
```
7. Deploy using the new Heroku remote:
```bash
$ git push heroku master
```
The console output should contain a public URL for your app.

### Surge

Expand Down