It would be nice to allow my Dart web app to hit different servers depending on what environment it was deployed on:
- DEV:
http://dev.myapp.com/someService
- QA:
http://testing.myapp.com/someService
- LIVE:
http://myapp.com/someService
In Java, typically you'd have a deployment descriptor (myapp.properties
) that the app reads off the runtime classpath, allowing you to specify a myapp.properties
on DEV like so:
service.url=dev.myapp.com/someService
And on QA like so:
service.url=qa.myapp/com/someService
etc. It looks like Dart offers something comparable however its server-side/command-line only...
So how do Dart web developers achieve the same thing, where you don't need to hardcode all of your various environments' servers into the app? (Obviously, this question extends beyond service URLs and really applies to any environment-specific property.)
You can use the String.fromEnvironment constant constructors to get values passed to the dart2js compilers. For a full explaination on this new functionality check out Seth Ladd's blog post: Compile-time dead code elimination with dart2js