Book Image

Beginning Server-Side Application Development with Angular

By : Bram Borggreve
Book Image

Beginning Server-Side Application Development with Angular

By: Bram Borggreve

Overview of this book

Equip yourself with the skills required to create modern, progressive web applications that load quickly and efficiently. This fast-paced guide to server-side Angular leads you through an example application that uses Angular Universal to render application pages on the server, rather than the client. You'll learn how to serve your users views that load instantly, while reaping all the SEO benefits of improved page indexing. With differences of just 200 milliseconds in performance having a measurable impact on your users, it's more important than ever to get server-side right.
Table of Contents (10 chapters)

Adding Run Scripts to package.json


Now that we have added a second application to our Angular CLI config, we need to make sure we can easily build both applications without having to memorize the exact commands.

In order to do so, we will leverage the so-called npm scripts. These scripts are used to define operations that can be performed on our application. Examples of these operations are building the application, running tests, and deploying the application to a staging or production environment.

We can define our npm scripts in the scripts section of the package.json file in the root of our project.

Here, we will add three scripts called build, build:browser, and build:server, where the first script will invoke the other two.

This gives us the flexibility to run the two commands at once, or run them independently if we like.

To get an idea of how these scripts work, consider the following flow:

  1. The npm run build command will first run npm run build:browser.

  2. When that command is finished, it...