Skip to content

Environment as external chunk #2929

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
michal-kroliczek opened this issue Oct 28, 2016 · 5 comments
Closed

Environment as external chunk #2929

michal-kroliczek opened this issue Oct 28, 2016 · 5 comments

Comments

@michal-kroliczek
Copy link

Hi,

this is feature proposition. I know already how environments should be use and it is quite ok. What would be nice is to put final environment.js as external chunk so it is loaded from environment.js located somewhere next to index.html.

Motivation:
I use docker for deployment. I found it really nice option to configure some properties (like backendUrl) at deployment time and not build time.

Having environemnt in external file it would be easy to override them when docker starts by providing env variables.

@intellix
Copy link
Contributor

I guess you're thinking of doing something like a sed replace on the environment chunk before deployment to a particular environment.

I wonder if this sort of functionality should wait until we have Universal merged because at that point, we can actually use environment variables and inline the configuration inside index.html upon serve. Your Docker container would be a node service at that point.

@michal-kroliczek
Copy link
Author

Yep using 'sed' is the way I thought of. Could you please give more details about using env variables? How will it work?

@intellix
Copy link
Contributor

intellix commented Oct 28, 2016

well ideally if you had an actual node app (NG Universal delivering index.html), we could inline the config inside there using middleware.

We could replace the original environment.ts values on runtime inside server.js like:

import { environment } from 'environments/environment';
environment.apiEndpoint = process.env.API_ENDPOINT;

// And then some middleware that inlines environment into index.html

@filipesilva
Copy link
Contributor

Dupe of #2508

@angular-automatic-lock-bot
Copy link

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.

@angular-automatic-lock-bot angular-automatic-lock-bot bot locked and limited conversation to collaborators Sep 6, 2019
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants