Created
November 21, 2016 08:19
-
-
Save jackinf/9398a01b115f4547daad9b8ca3aa3509 to your computer and use it in GitHub Desktop.
Micro server file for serving compiled app
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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