Angular-cli: Feature req: Environment specific assets/ angular-cli files

Created on 21 Jan 2017  路  12Comments  路  Source: angular/angular-cli

Currently, one can add asset folders by adding them to angular-cli.json's assets key. These assets will always be added regardless of environment.

I need to add test assets (stub-data) for test/development environments only - they should not be added to production. Hence I would like, angular-cli to support specifying different sets of asset folders depending on the build environment.

Another more general option, would be for angular-cli to support multiple angular-cli*.json files (additional files with environment specific overrides).

Most helpful comment

All 12 comments

I know some users are adding stubs via the environment files (see https://github.com/angular/angular-cli/issues/3940) but I understand your request is different.

I'll tag it for discussion but don't have any plans to add it for now.

Thanks for the link. Yes, my case is different. I need to add different json files (and other resource files) depending on the environment.

@filipesilva Just found out that the "apps" option in angular-cli.json is really an array although it seems only first element is currently supported. If angular was changed to fully support multiple elements in the configuration "apps" array than my use case (and many, many other use-cases) would be solved!

+1, need to load different images for different environments

+1, We're going through the same problem, right now. Environment based assets would be beneficial.

Heya @mmc41, you can now use the apps array as documented here: https://github.com/angular/angular-cli/blob/master/docs/documentation/stories/multiple-apps.md

@filipesilva The story is also missing in the stories directory:
https://github.com/angular/angular-cli/wiki/stories

Is this feature still available in Angular 8?

Currently, I have several directories:

  • src/assets/images/customer1
  • src/assets/images/customer2
  • src/assets/images/customer3

After the build, the folder of the configured customer should be available 1 directory level higher.
E.g. when running ng serve --app=customer1 all files in src/assets/images/customer1 should be available in src/assets/images. None of the other customer's assets should be available there.

(I've taken a look at the links above, but they either refer to the old angular-cli.json file or didn't contain any helpful information to solve my problem)

@takahser Instead you could have:

  • assets/ (shared assets)
  • assets/customer1/
  • assets/customer2/
  • assets/customer3/

And then you can add it to the build of each customer:

"assets": [
                "src/assets",
                {
                  "glob": "**/*",
                  "input": "src/assets/customer1",
                  "output": "/assets"
                }
],

@MickL thanks, that worked 馃憤馃徏

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._

Was this page helpful?
0 / 5 - 0 ratings