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

Heroku instructions based on express server #2998

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

### Heroku

> TODO | Open to contribution.
1. Create a `server.js` file in the root of your project
1. Add post install and start scripts to your `package.json` file
1. Install expressjs `npm install --save express`
1. You might need to add `es6-promise` as a dev dependency (`npm install --save-dev es6-promise`)

```javascript
// server.js
const express = require('express')
const path = require('path')
const serveStatic = require('serve-static')

const app = express()
app.use(serveStatic(path.join(__dirname, '/dist')))

app.use((req, res, next) => {
res.status(404)

if (req.accepts('html')) {
res.sendFile(path.join(__dirname, '/dist/index.html'))
return
}

if (req.accepts('json')) {
res.send({ error: 'Not found' })
return
}

res.type('txt').send('Not found')
})

var port = process.env.PORT || 80
app.listen(port)

console.log('Your vue app is being hosted on port ' + port)
```

```json
// package.json
...
"postinstall": "npm run build",
"start": "node server.js"
...
```

### Surge

Expand Down