Last active
August 10, 2017 16:25
-
-
Save davideast/ea36fb57faade29e54392548dde09c33 to your computer and use it in GitHub Desktop.
Angular Universal Express Sample
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
import { angularUniversal } from 'angular-universal-express'; | |
import * as express from 'express'; | |
const app = express(); | |
/* | |
I usually copy my Angular CLI "dist" build into my "dist-server" build | |
and serve them as static files so they aren't treated as dynamic routes. | |
*/ | |
app.use(express.static(__dirname + '/dist')); | |
app.get('/*', angularUniversal({ | |
index: 'path/to/index.html', | |
main: 'path/to/main.<some-long-hash>.bundle', | |
enableProdMode: true | |
})); | |
app.listen(3005, () => { console.log('Listening on 3005'); }); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment