Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Beginning Server-Side Application Development with Angular

You're reading from   Beginning Server-Side Application Development with Angular Discover how to rapidly prototype SEO-friendly web applications with Angular Universal

Arrow left icon
Product type Paperback
Published in Apr 2018
Publisher
ISBN-13 9781789342161
Length 110 pages
Edition 1st Edition
Languages
Tools
Arrow right icon
Author (1):
Arrow left icon
Bram Borggreve Bram Borggreve
Author Profile Icon Bram Borggreve
Bram Borggreve
Arrow right icon
View More author details
Toc

Adding Dependencies for the Server App


In order to get our server app working correctly, we need to make sure we load two of Angular's dependencies: zone.js and reflect-metadata.

Our browser app loads these dependencies using polyfills.ts, and for the server app, we will add them to src/main.server.ts.

Another dependency that we need to add is the ModuleMapLoaderModule. This is a third-party module that is needed to make Angular Universal apps work with lazy loading.

We will import two dependencies in src/main.server.ts so that they are imported when the AppServerModule is loaded.

Additionally, we will enable production mode, just like it's done for the browser app in src/main.ts:

  1. Open the newly created file src/main.server.ts.

  2. Add the imports at the top of the file:

    import 'zone.js/dist/zone-node';
    import 'reflect-metadata';
    
    import { enableProdMode } from '@angular/core';
    import { environment } from './environments/environment';
  3. Conditionally enable production mode, depending on the environment...

lock icon The rest of the chapter is locked
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at €18.99/month. Cancel anytime