Reputation: 53850
I have a link to dart source file to develop and debug my app and a link to JS bundle file for production.
I think about putting them together like this:
<script type="application/dart" src="app.dart"></script>
<script src="app.js"></script>
I suppose regular browsers will ignore first link and use second one. But, which of them will run in Dartium?
Should I put them together at all or should I put dart for development and js in the release dynamically?
Upvotes: 2
Views: 52
Reputation: 4005
The recommended way is to have these tags in your page:
<script type="application/dart" src="app.dart"></script>
<script src="packages/browser/dart.js"></script>
The dart.js file is used to check for native Dart support and either download the Dart script or load compiled JS. See this page for more info: https://www.dartdocs.org/documentation/browser/0.10.0%2B2/
When you build your app for deployment you should replace the 2 tags with the Javascript version.
<script src="app.dart.js"></script>
You could do this automatically with the dart_to_js_script_rewriter
transformer.
See https://pub.dartlang.org/packages/dart_to_js_script_rewriter
For this to work, you should have this in your pubspec.yaml
dependencies:
browser: any
dart_to_js_script_rewriter: any
transformers:
- dart_to_js_script_rewriter
Upvotes: 4