Angular-cli: Add documentation for --browser-target

Created on 7 Jan 2020  路  9Comments  路  Source: angular/angular-cli

馃摎 Docs or angular.io bug report

Description

There's no documentation for ng serve --browser-target.

馃敩 Minimal Reproduction

What's the affected URL?

Reproduction Steps


馃摲Screenshot


Screen Shot 2020-01-07 at 09 47 16

devkibuild-angular low good first issue help wanted confusing docs

Most helpful comment

The browserTarget property says what build target is going to be served. The serve command doesn't completely know how to build it, it just knows how to serve it.

Usually there's only one build, but since a target can have multiple configurations, you can specify that you want to serve that particular configuration of the build. There's some more information about it in this AIO page.

In practical terms what this means is that ng serve will serve the development build and ng serve --prod will serve the production build.

The way this is specified is through browserTarget. In a default angular.json you'll have this:

{
  "projects": {
    "next-app": {
      ...
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": { ... }
          "configurations": {
            "production": { ... }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "next-app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "next-app:build:production"
            }
          }
        },

Where "browserTarget": "next-app:build" means "I want to serve projects->next-app with the default options" and "browserTarget": "next-app:build:production" means "I want to serve projects->next-app with the default options merged with the production config".

Does this description help?

All 9 comments

Woah, that issue template is a pain to work with.

Would you like to add more details to this doc? That string is extracted from json files in this repo, and should be the 3 results for "Target to serve" if you search across the code.

I'd love to, but I have no idea what it does nor how to use it. That's why I was referring to the docs.

The browserTarget property says what build target is going to be served. The serve command doesn't completely know how to build it, it just knows how to serve it.

Usually there's only one build, but since a target can have multiple configurations, you can specify that you want to serve that particular configuration of the build. There's some more information about it in this AIO page.

In practical terms what this means is that ng serve will serve the development build and ng serve --prod will serve the production build.

The way this is specified is through browserTarget. In a default angular.json you'll have this:

{
  "projects": {
    "next-app": {
      ...
      "architect": {
        "build": {
          "builder": "@angular-devkit/build-angular:browser",
          "options": { ... }
          "configurations": {
            "production": { ... }
        },
        "serve": {
          "builder": "@angular-devkit/build-angular:dev-server",
          "options": {
            "browserTarget": "next-app:build"
          },
          "configurations": {
            "production": {
              "browserTarget": "next-app:build:production"
            }
          }
        },

Where "browserTarget": "next-app:build" means "I want to serve projects->next-app with the default options" and "browserTarget": "next-app:build:production" means "I want to serve projects->next-app with the default options merged with the production config".

Does this description help?

@NatoBoram I have some spare cycles if you'd like to hand this off. Alternatively, I'd be happy to collaborate instead if you'd still like to be involved. I wrote some of the Python docs, and would be happy to mentor. And, of course, happy to let you do your thing -- but please update us either way.

@domthewop You're free to work on it :)

Is this still up for grabs?

Go for it, @rrohak -- I left Google in the interim and didn't update the ticket, sorry!

Would you like to add more details to this doc? That string is extracted from json files in this repo, and should be the 3 results for "Target to serve" if you search across the code.

Here you said there are 3 results but IntelliJ only shows 2, are we including serve.md under docs/documentation or am I missing another file? @filipesilva
image

Was this page helpful?
0 / 5 - 0 ratings