Skip to content

Default projects and configurations #11233

Closed

Description

@listepo-alterpost

Bug Report or Feature Request (mark with an x)

- [ ] bug report -> please search issues before submitting
- [x] feature request

Area

- [x] devkit
- [ ] schematics

We have many projects in the repository and now there is a lot of copy-paste in the angular.json

There is a proposal to add defaultConfigurations, defaultProjects and be able to inherit that.

Example

{
  "defaultProjects": {
    "defaultApp": {
      "root": "apps/$appName",
      "sourceRoot": "apps/$appName/src",
      "projectType": "application"
    }
  },
  "defaultConfigurations": {
    "defaultProd": {
      "aot": true,
      "optimization": true,
      "sourceMap": true,
      "outputHashing": "all",
      "namedChunks": false,
      "commonChunk": true,
      "buildOptimizer": true
    }
  },
  "projects": {
    "app": {
      "extend": "defaultApp",
      "configurations": {
        "prod": {
          "extend": "defaultProd",
          "extractCss": true,
          "extractLicenses": true,
          "vendorChunk": false
        }
      }
    }
  }
}

Activity

  1. MickL commented on Jun 14, 2018

    @MickL

    Would love to see that, too! I have two apps already that need exactly this:

    The app is the same but depending on the build the assets, styles or even some components need to change. This is already possible by use of the projects or configuration and then ng build customer1, ng build customer1 OR ng build configuration=customer1 and ng build configuration=customer2. But without extend functionality this creates TONS of duplicate configration code.

    Btw. file replacement for all file types is already implemented in upcoming release 6.1.0. E.g. you can then replace component-a.ts with component-b.ts for one build. Anyway, without the extend functionality, we have to create tons of duplicate code as you mentioned.

  2. added
    featureLabel used to distinguish feature request from other issues
    on Jun 18, 2018
  3. fetis commented on Oct 19, 2018

    @fetis

    Do you think it's possible to achieve with schematics? I'm thinking about having a template config and expand it to many variations into angular.json with some schematic or NodeJS script. What do you think?

  4. wulfsberg commented on Oct 19, 2018

    @wulfsberg

    I am generally wary of the "autogenerate lots of clunky configuration" idea.
    It tends to be brittle, in particular between updates, and makes things hard to debug as we essentially invent yet another language. This was the "Turing-complete XML configuration" hell Java went through, with the same vision of "you just need to right-click in your IDE and not worry about the 400Kb XML which suddenly appeared. (Except when something did go wrong, as it inevitably will)".

  5. fetis commented on Oct 19, 2018

    @fetis

    But other option is only a lot of error-prone and tedious manual updates.

  6. filipesilva commented on Jan 29, 2019

    @filipesilva
    Contributor

    Heya, this request looks to be very similar to #10612. I'm closing in favor of that one to keep the discussion in one place.

  7. angular-automatic-lock-bot commented on Sep 9, 2019

    @angular-automatic-lock-bot

    This issue has been automatically locked due to inactivity.
    Please file a new issue if you are encountering a similar or related problem.

    Read more about our automatic conversation locking policy.

    This action has been performed automatically by a bot.

  8. locked and limited conversation to collaborators on Sep 9, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    featureLabel used to distinguish feature request from other issues

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions