6

I'm using angular-cli (beta 26). For local development it's great, but I'm struggling to see how it can fit into a more serious "build once, deploy many" type of pipeline?

I'm using the built-in concept of an environment to store environment specific information, e.g. connection strings. But I'm required to specify the environment at build time, by using ng build --environment=xyz. This basically means I have to do a fresh build for every deployment. Idealy I'd like to select my environment at runtime (much like can be done with ASP.NET Core for example).

Am I missing something here? Is there another way to solve this problem?

1
  • 1
    We had a similar problem, wanting to have different environments with different IDs for an analytics service; we ended up using SSI to include the tracking code at serve time, and dropping in the appropriate ID in an HTML file at deploy time, which isn't ideal... Commented Jan 27, 2017 at 14:17

2 Answers 2

5

This was quite thoroughly discussed in the https://github.com/angular/angular-cli/issues/3855#issuecomment-274803729. Probably you know the answer already, but since it's not linked here I'm posting so anyone can see it.

Basically angular-cli environments are designed to be build-connected, so we have to custom-load e.g. a json file with runtime config.

Sign up to request clarification or add additional context in comments.

Comments

0

I missed this awesome guide by juristr the first time I've checked the accepted answer's link and just want to have it here separately. I picked up from multiple sources (and lots of trying) the same things which are really nicely broken down in detail in that guide. So if you would ever be in those shoes, I would gladly recommend to go through it!

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.