question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

ng run project:server universal production not possible

See original GitHub issue

Versions

Angular CLI: 6.0.0-rc.5
Node: 8.11.1
OS: darwin x64
Angular: 6.0.0-rc.5
... animations, cli, common, compiler, compiler-cli, core, forms
... http, language-service, platform-browser
... platform-browser-dynamic, platform-server, router
... service-worker

Package                           Version
-----------------------------------------------------------
@angular-devkit/architect         0.5.7
@angular-devkit/build-angular     0.5.7
@angular-devkit/build-optimizer   0.5.7
@angular-devkit/core              0.5.7
@angular-devkit/schematics        0.5.7
@angular/cdk                      6.0.0-rc.11
@angular/material                 6.0.0-rc.11
@ngtools/json-schema              1.1.0
@ngtools/webpack                  6.0.0-rc.5
@schematics/angular               0.5.7
@schematics/update                0.5.7
rxjs                              6.0.0-uncanny-rc.7
typescript                        2.7.2
webpack                           4.5.0

Repro steps

ng build --prod && ng run client:server

This builds the app in production mode but the universal server app uses the dev environment rather than production

I probably just missing something in my config but not sure what.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:20 (6 by maintainers)

github_iconTop GitHub Comments

13reactions
beemancommented, May 20, 2018

This is how I got it working:

I created a configurations.production object in my server object:

"server": {
  "builder": "@angular-devkit/build-angular:server",
  "options": {
    "outputPath": "dist/store-server",
    "main": "src/main.server.ts",
    "tsConfig": "src/tsconfig.server.json"
  },
  "configurations": {
    "production": {
      "fileReplacements": [
        {
          "replace": "src/environments/environment.ts",
          "with": "src/environments/environment.prod.ts"
        }
      ]
    }
  }
}

And I have this in my build run-script:

ng build store --prod && ng run store:server:production

This made my server side app read the production environment.

3reactions
hakobpoghcommented, May 13, 2018

and what about --watch? I think that it’s also should be available for ng run.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Angular development build does not run while prod build does
to run angular universal app in dev mode you need to run this command: npm run dev:ssr. or: ng run project:serve-ssr.
Read more >
Angular workspace configuration
Configures defaults for creating a Universal application with server-side rendering, using the ng run <project>:server command. architect/app-shell, Configures ...
Read more >
Angular workspace configuration
The architect/server section configures defaults for creating a Universal app with server-side rendering, using the ng run <project>:server command.
Read more >
Angular Universal: Complete Practical Guide
This post will be a complete practical guide for getting started with Angular Universal. We are going to go start with an existing...
Read more >
Server-side Rendering using KoaJS and Angular Universal
Which simply means that you can run your Angular application not only the browser but on the ... "ng build --prod && ng...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found