Dart web application environment variables

It would be nice to allow my Dart web application to delete different servers depending on the environment in which it was deployed:

  • DEV: http://dev.myapp.com/someService
  • QA: http://testing.myapp.com/someService
  • LIVE: http://myapp.com/someService

In Java, as a rule, you will have a deployment descriptor ( myapp.properties), which the application reads from the path of the execution path, allowing you to point myapp.propertiesto the DEV, for example:

service.url=dev.myapp.com/someService

And on QA like this:

service.url=qa.myapp/com/someService

etc .. It seems that Dart offers something comparable , but only its server / command line ...

So, how do Dart web developers achieve the same where you don’t need to hardcode all the servers of your various environments in the application? (Obviously, this question goes beyond the URLs of the service and really applies to any environment-specific property).

+4
2

String.fromEnvironment , dart2js. Seth Ladd: dart2js

+5

, html, .

, ( ) html

<script>
  // var serviceUrl = "@VALUE_OF_VAR@";
  var serviceUrl = "dev.myapp.com/someService";
</script>

dart:

import 'dart:js' as js;
main() {
  var serviceUrl = js.context['serviceUrl'];
}
+2

All Articles