How to implement SSR with Angular 6 and AngularFire2

ChrisEenberg

I'm following this tutorial to setup SSR with AngularFire2. This guide is, however, "only compliant with Angular 5" it seems - SSR with angularfire2

My problem is: when I get to the step where I need to setup angular-cli.json (now known as angular.json in Angular 6) the structure is completely rewritten. Is there any way to add multiple build targets, as the tutorial suggests?

I've tried adding an array entry for the architect build section (kind of like the "old" way of adding an array of apps in angular-cli.json), but without luck - I get, "object expected here" - it looks something like this:

    "build": [{
      "builder": "@angular-devkit/build-angular:browser",
      "options": {
        "outputPath": "dist/browser",
        "index": "src/index.html",
        "main": "src/main.ts",
        "polyfills": "src/polyfills.ts",
        "tsConfig": "src/tsconfig.app.json",
        "assets": [
          "src/favicon.ico",
          "src/assets"
        ],
        "styles": [
          "src/styles.scss",
          "src/assets/foundation-icons/foundation-icons.css"
        ],
        "scripts": []
      },
      "configurations": {
        "production": {
          "fileReplacements": [
            {
              "replace": "src/environments/environment.ts",
              "with": "src/environments/environment.prod.ts"
            }
          ],
          "optimization": true,
          "outputHashing": "all",
          "sourceMap": false,
          "extractCss": true,
          "namedChunks": false,
          "aot": true,
          "extractLicenses": true,
          "vendorChunk": false,
          "buildOptimizer": true
        }
      }, ... // new build target here ]

Is there a way to achieve the same result with the new json structure of angular 6, here I'm only talking about setting up the config information for angular.json?

I can provide more information if need be.

Kind regards Chris.

kekdahl

Under the architect configuration, you can add the configuration for the server-side app, similar to how you configured the app in the .angular-cli.json.

architect: {
...
"server": {
      "builder": "@angular-devkit/build-angular:server",
      "options": {
        "outputPath": "dist-server",
        "main": "src/main.server.ts",
        "tsConfig": "src/tsconfig.server.json"
      }
    }
}

Notice that this is not under the build property. Then to build this code to the dist-server, you can run

ng run myProject:server

This was the default configuration provided by running ng upgrade after installing the new CLI, but figuring out the ng run command was a lot of trial and error. :)

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Angular 6 and AngularFire2 RxJS Error

reverse an observable array in angularfire2 angular 6

Angular 4 with AngularFire2

Can not have access to multiple Google Firestore DB in Angular 6 application with angularfire2

How to Query in angularfire2

Angular2, Firebase, AngularFire2, route guard and how to deal with subscription

How to do a multi-location "remove" with AngularFire2 or Firebase in Angular2

How to prevent DOM replacement in angular2 ngFor async in angularfire2?

How can I sort a FirebaseListObservable list in Angularfire2 Angular2?

How to implement AntiForgery Token in Angular with NET 6

How to get current authenticated user angularfire2 (angular) so that it is usable in time for class methods?

In Angular (using angularfire2 and typescript) how do you get types on errors thrown when using firestore?

Firebase - Firestore - Angularfire2 - Angular : How do I access key values within the controller?

How to add collection within document + angularfire2 + angular5

Angular2 and Firebase (AngularFire2)

TypeError: changes.payload.docChanges is not a function in Angular 6 using AngularFire2 v5-rc9

Angular not pulling data through Angularfire2

Angularfire2 compiling issues in Angular 5.2

Angular 6: How to implement Pagination and Sorting on Angular Material Table

How to build angularfire2 for production

Angularfire2 how to combine two list

How to create GeoPoint from angularfire2?

How to join documents with AngularFire2?

how to rollback angularfire2 4.0, back to angularfire 2 2.0?

How to implement Scroll animation in Angular 8 with rxjs 6?

How to implement a debounce time in keyup event in Angular 6

How do i implement a data filled dropdown list with Angular 6

How can I implement LoginComponent using Angular 6?

How to implement generic error handling that works with forkJoin in Angular 6?

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  3. 3

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  4. 4

    pump.io port in URL

  5. 5

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

  9. 9

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  10. 10

    How to remove the extra space from right in a webview?

  11. 11

    java.lang.NullPointerException: Cannot read the array length because "<local3>" is null

  12. 12

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  13. 13

    flutter: dropdown item programmatically unselect problem

  14. 14

    How to use merge windows unallocated space into Ubuntu using GParted?

  15. 15

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  16. 16

    Nuget add packages gives access denied errors

  17. 17

    Svchost high CPU from Microsoft.BingWeather app errors

  18. 18

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  19. 19

    12.04.3--- Dconf Editor won't show com>canonical>unity option

  20. 20

    Any way to remove trailing whitespace *FOR EDITED* lines in Eclipse [for Java]?

  21. 21

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

HotTag

Archive