Skip to content

Instantly share code, notes, and snippets.

@guilatrova
Last active December 10, 2017 12:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save guilatrova/68c0836e6f59c069dced32bef8ab4a5f to your computer and use it in GitHub Desktop.
Save guilatrova/68c0836e6f59c069dced32bef8ab4a5f to your computer and use it in GitHub Desktop.
Latrova Commits Deploy /dist to Heroku with Express
{
...
"engines": {
"node": "6.11.1",
"npm": ">=3"
},
"scripts": {
...
"build": "babel-node tools/build.js && npm run open:dist",
"heroku-prebuild": "",
"heroku-postbuild": "babel-node tools/build.js",
...
},
...
}
web: node server.js
/* eslint-disable */
var express = require('express');
var path = require('path');
var port = process.env.PORT || 3000;
var app = express();
app.use(express.static(path.join(__dirname, 'dist')));
app.get('*', (_req, res) => {
res.sendFile(path.join(__dirname, 'dist/index.html'));
});
app.listen(port, (err) => {
if (err) {
console.log(err);
} else {
console.log(`server started port: ${port}`);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment