Reputation: 4908
I trying my luck on Dart. I've got an application that loads the Dart file and the generated Javascript:
<script type="application/dart" src="/bones/build/web/quiz/quiz1.dart">
</script>
<script src="/bones/build/web/quiz/quiz1.dart.js">
</script>
When I open this page in Dartium, both the Javascript and the Dart code are run (I only need one).
How do I go about to run only the Dart file, and not the Javascript when opened in Dartium, and run the Javascript when opened in Firefox or Chromium?
Should I create two pages, one for Dart and one for Javascript? That means I'd have to edit two files when I want to change anything. Feels wrong to me.
Kind regards, Hendrik Jan
---- EDIT ----
I now realise that it might be important that this application is written in PHP using the Laravel framework.
Upvotes: 0
Views: 152
Reputation: 4908
I found the following solution that works for me. In stead of linking to the generated Javascript file (as I did in my question), I link to dart.js
which will load the generated Javascript in case Dart is not supported in the browser, like this:
<script type="application/dart" src="/bones/build/web/quiz/quiz1.dart">
</script>
<script src="/bones/build/web/packages/browser/dart.js">
</script>
This makes it possible for me to see the result of my work in Dartium and also in Firefox and Chromium.
Upvotes: 3
Reputation: 657536
You don't have to do anything, let pub build
/pub serve
handle how the script tags are included into the entry page.
The problem is that you can't build deployable Dart code. dart2dart
is experimental and not yet supported (see Run Dart WebApp on Apache Server for more details on dart2dart
).
If you use pub serve
a Dart capable browser runs the Dart code and a browser that doesn't support Dart runs the code built to JavaScript.
Dartium is also only for development and therefore there is no browser out there that processes Dart code. As far as I know the Dart team tries to have dart2dart ready when Chrome supports Dart.
But for development using pub serve
it's just fine and you don't have to do anything special.
Upvotes: 0