Skip to content

Instantly share code, notes, and snippets.

@jackinf
Created November 21, 2016 08:19
Show Gist options
  • Save jackinf/9398a01b115f4547daad9b8ca3aa3509 to your computer and use it in GitHub Desktop.
Save jackinf/9398a01b115f4547daad9b8ca3aa3509 to your computer and use it in GitHub Desktop.
Micro server file for serving compiled app
const express = require('express');
//const exec = require('child_process').exec;
require('shelljs/global');
const path = require('path');
const port = process.env.PORT || 3000;
const app = express();
// serve static assets normally
app.use(express.static(__dirname + '/dist'));
// handle every other route with index.html, which will contain
// a script tag to your application's JavaScript file(s).
app.get('*', function (request, response){
response.sendFile(path.resolve(__dirname, 'dist', 'index.html'))
});
app.listen(port);
console.log("server started on port " + port);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment