AngularDart Transformation/Deployments

Issue

I am building a client/server app in Dart using Angular for the front-end and Shelf on the backend. When I do a pub build it generates the javascript for the Dart files as expected but is does not replace the dart references in my HTML files. So in my index.html I have the following script reference:

<script type="application/dart" src="main.dart"></script>

This makes my application not load correctly. If I manually change it to

<script src="main.dart.js"></script>

My application works as expected. My question is, is there a way to configure my pub build to do this automatically? Or are dart files references not supposed to be replaced with JS references? If so, how do I build a basic server?

Solution

I know this produces an error message in the browser console but never experienced any problems because of this.

I haven’t used it myself yet but I think this transformer https://pub.dartlang.org/packages/dart_to_js_script_rewriter does what you want.

Answered By – Günter Zöchbauer

Answer Checked By – Mildred Charles (FlutterFixes Admin)

Leave a Reply

Your email address will not be published. Required fields are marked *