-
Notifications
You must be signed in to change notification settings - Fork 309
environment variables #370
Comments
Hi @kodeine, Right now I don't think there is a good way to do it. This is something we should address in the coming weeks. Thanks, |
I was trying to get the same functionality i.e environment based global variables similar to Angular cli. I am doing this right now as below. Create new file ->
Add this config to package.json
Define global environment variables in
In your code you import as below and use
And then run
|
@danbucholtz please update this when the env variables are ready to be used. Thanks for everything! |
This should be landing soon. We aren't going to do it exactly this way but we'll do something similar. Thanks, |
I've had to turn off ngc/AoT for the approach described by @harshabonthu
Otherwise I get a runtime exception in Chrome Inspector, that I need a loader:
Perhaps by the time webpack runs environments/environment is not available? |
@kwv I've uploaded sample project here -> https://github.com/harshabonthu/ionic2-env-sample/commit/08dae6ec86a30d932cdccb3ccd2df8be1b869220 Running |
@danbucholtz I'm curious when "soon" is 😄 Any updates with as of late? |
This is a lower priority for us right now. I put in a PR for this but the team rejected my impl so we are going back to the drawing board about this. We will eventually implement this but we are very focused on better dead code elimination and tree shaking. Thanks, |
@danbucholtz While this is low priority for you, for many of us it's very important to have a way of switching configuration based on which env we are using. I've literally looked through all PR's in this repo and I could not find any implementation of a possible solution, but #204, which with Webpack it's not working for production builds with AOT. And Rollup cannot be used if I also use So it is becoming a little frustrating. It would be nice to finally see some progress on this matter. Or at least some design document that we could use to make an implementation ourselves. |
While not something official this is what we currently do for our project. I don't know how this interacts with ionic cloud necessarily since we aren't using that yet. We have a scripts dir which wraps the ionic-app-scripts build/watch functions and a template which we inject anytime we run it where we can place env variables. Below is a gist showing an example. https://gist.github.com/riltsken/906bace69b65168551ae089f5ae106cb |
Let's track this here: Thanks, |
How to define env variables globally? in
src/app/main.dev.ts
andsrc/app/main.prod.ts
?The text was updated successfully, but these errors were encountered: