Uh oh!
There was an error while loading. Please reload this page.
Add environment config to builds - #411
Conversation
hansl
commented
Apr 8, 2016
This LGTM, let's see what comes out of the discussion in styleguide. |
hansl
commented
Apr 8, 2016
So after working with Igor and Filipe during the meeting, here's the path forward:
declarevar__ENV__ : {[name: string]: any};exportdefault__ENV__;
importenvironmentfrom'environment';// ...if(environment.production){enableProdMode();}
|
hansl
commented
Apr 8, 2016
What do you think? |
filipesilva
commented
Apr 9, 2016
I like the simpler I guess it caters to the server-side rendering scenario by moving the logic elsewhere, so the bootstrap doesn't have to be more complex. Now that I think of it, on apps with a lot of nested routes I'd much prefer to have a provider I can use than to do What's the usecase for having a default template? Is this something you've felt the need for? I haven't yet, but that doesn't mean it's not useful. I'm not too keen on putting stuff on In this scenario, we create End result would be the same, without having to fiddle with |
hansl
commented
Apr 9, 2016
So in Django you get a default set of options for the environment, which is overwritten by the environment that you need. So something like this exists: // environment.default.tsexportdefault={production: false,backendUrl: 'http://localhost:9999/',firebaseUrl: 'http://blah/',};// environment.dev.tsimportDEFAULTSfrom'./environment.default'exportdefault=Object.assign(DEFAULTS,{});// environment.e2e.tsimportDEFAULTSfrom'./environment.default'exportdefault=Object.assign(DEFAULTS,{production: true,// Use same backends as DEV});// environment.prod.tsimportDEFAULTSfrom'./environment.default'exportdefault=Object.assign(DEFAULTS,{production: true,backendUrl: 'http://blah',firebaseUrl: 'http://bleh/',});I guess the default could always be DEV, but it's better to dissociate DEV from anything else since it might lead to mistakes and expose data you don't want to. |
filipesilva
commented
Apr 9, 2016
Thinking a bit more about That way the provider can be a straight up import of |
filipesilva
commented
Apr 9, 2016
Ok the defaults make more sense now. These env files seem the perfect place to add the firebase info, and even APP_BASE_HREF (github deploys need a specific one, for instance). |
a494333 to
0e5117dComparefilipesilva
commented
Apr 9, 2016
Removed provider, but didn't incorporate the defaults because it made the process more complicated when using more environments that don't extend dev ( |
hansl
commented
Apr 9, 2016
We already have a |
filipesilva
commented
Apr 9, 2016
I thought about it at the start, but then assumed it would be problematic because of the whole But with you mentioning it now I agree it's much better to have those files out of the client and in config. |
0e5117d to
23b5d5eCompare| import {<%= jsComponentName %>App} from './app/<%= htmlComponentName %>'; | ||
| bootstrap(<%= jsComponentName %>App, []); | ||
| if (environment.production) { enableProdMode(); } |
There was a problem hiding this comment.
Split the lines, this might trigger the linter :)
hansl
commented
Apr 12, 2016
Can you add the overwriting of the environment by the build system in this PR? Then I think this will be ready to go. |
23b5d5e to
c7b333aComparec7b333a to
8e4885cComparefilipesilva
commented
Apr 12, 2016
@hansl done, please review. |
b7c5c90 to
d6db64fComparefilipesilva
commented
Apr 13, 2016
@hansl tests are fixed. |
hansl
commented
Apr 13, 2016
LGTM. We should add support for multiple builds in the future, but for now this is 👍. |
filipesilva
commented
Apr 13, 2016
@hansl agree, atm just wanted to get something in this week. |
d6db64f to
372354fCompareThis 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. |
See #41 (comment)
Environments
At build time, the
src/client/app/environment.tswill be replaced by eitherconfig/environment.dev.tsorconfig/environment.prod.ts, depending on thecurrent cli environment.
Environment defaults to
dev, but you can generate a production build viathe
-prodflag in eitherng build -prodorng serve -prod.