Skip to content

Instantly share code, notes, and snippets.

@kevinn
Created April 12, 2019 12:52
Show Gist options
  • Save kevinn/39baa4186289b15f0cb5322b02a28995 to your computer and use it in GitHub Desktop.
Save kevinn/39baa4186289b15f0cb5322b02a28995 to your computer and use it in GitHub Desktop.
Deploy Vue.js app /dist to Heroku
  1. Add express and serve-static via npm:
$ npm install express serve-static
  1. Create file named heroku.js on at the root directory of a Vue.js project:
const express = require('express');
const serveStatic = require("serve-static")
const path = require('path');
app = express();
app.use(serveStatic(path.join(__dirname, 'dist')));
const port = process.env.PORT || 80;
app.listen(port);
  1. In package.json add the ff to the scripts section:
"postinstall": "npm run build",
"start": "node heroku.js"

Then add the project to your Heroku and deploy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment