Skip to content

Instantly share code, notes, and snippets.

@davideast
Last active August 10, 2017 16:25
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 davideast/ea36fb57faade29e54392548dde09c33 to your computer and use it in GitHub Desktop.
Save davideast/ea36fb57faade29e54392548dde09c33 to your computer and use it in GitHub Desktop.
Angular Universal Express Sample
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