This project was generated with Angular CLI version 1.0.0-rc.1.
- Terminal 1:
npm run watch:all
- Wait for the build to finish
- Terminal 2:
npm run server
npm run build:all:aot
npm run server
Add this script to the body of your index.html
<script>
if ('serviceWorker' in navigator) {
navigator.serviceWorker.register('/service-worker.js').then(function(registration) {
console.log('Service Worker registered');
}).catch(function(err) {
console.log('Service Worker registration failed: ', err);
});
}
</script>
And run these commands
npm run build:all:aot
npm run sw
npm run server
Based on and huge thanks to @FrozenPandaz: FrozenPandaz/ng-universal-demo
Based on and huge thanks to @robwormald: robwormald/ng-universal-demo