-
Notifications
You must be signed in to change notification settings - Fork 12k
Multiple environment.ts are confusing #933
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
Comments
Posted on how to use and the drawbacks here: https://tattoocoder.com/angular-cli-using-the-environment-option/ interface, at least in the current folder structure is not a good workflow. The interface would either need to be at the base root of the project or in a place where referencing it doesn't make sense. |
fwiw, we get by just fine without |
Also it would be great if we could make parent configuration, which _config/environment.base.ts_
_config/environment.dev.ts_
currently EmberCli base project reads and compiles only specific file based on version (prod or dev) _angular-cli/lib/broccoli/environment.js_
So what I'm saying is that you can't import something and extend it later |
@SergeySolonko this doesn't require special angular-cli support, i believe. Simply put |
@sgbeal Ok, got it |
Hi guys, |
just my 2 cent
|
I believe this is resolved with the webpack version of CLI |
@randyaa I agree. Originally the functionality was more confusing and less documented than it is now. Documentation can be found https://github.com/angular/angular-cli#build-targets-and-environment-files, and now the third file is not needed. |
@filipesilva |
@matodrobec Hi, you can create workaround for your case, just simply add
and then you can easily import environment through In
You have to use '../' because |
I followed the above process, But I got this error --> src/app/app.component.ts (17,22): Cannot find namespace 'environment' |
I am really surprised how hard it is to find a simple tutorial/solution for cmd webpack -p --env.prd true and an environment configuration being available in an Angular2 Typescript app, I developed a very simple solution https://github.com/Sweetog/yet-another-angular2-boilerplate |
This issue has been automatically locked due to inactivity. Read more about our automatic conversation locking policy. This action has been performed automatically by a bot. |
The current model for environment variables is to have 3 places for files:
/src/environment.ts
This is here so when we type in VS Code or our favorite editor we get intellisense. it is not used for a build
/config/environment.dev.ts
and/config/environment.prod.ts
This is where we put our env settings for the different environments. It is copied to the
dist/
folder./dist/environment.js
This is the one that gets run, we do not edit this one.
Follow this scenario ... we need an env variable to point to a web url for our APIs. So we create a
and we put it in
/src/environment.ts
. We then import it withimport { environment } from './environment
. VS Code is happy (as is any tsc compiler command).Now we run
ng serve
and browse to the app, and we see an error in the console about how it doesnt know whaturl
is. Oops, we didnt put this in theconfig/environment.dev.ts
(nor prod) files. OK, so we go do that and now we can run and serve smoothly.Now ... we add a new env for
showDebugMessages: true
. We set it totrue
for dev andfalse
for prod. We recall that we need to do this in the/config/environment.*.ts
files so we feel we are good. But we forgot we also need to put the same setting in the/src/environment.ts
. It is not used ... but we need something there. Do we outfalse
ortrue
for this new setting? It doesn't matter because we are not using it.My point here is that it can be confusing on how to do this and not make a mistake.
Are there any thoughts on how to prescribe this? Or how to make it easier? Have you considered an interface?
My Env:
cc @spboyer
The text was updated successfully, but these errors were encountered: