Search code examples
dartdart-editor

customize dart compilation (paths in script element)


I was wondering if it is possible to customise how dart tool compiles the app. In particular I am interested in customizing the paths that appear in script elements.

At the moment I have my app in "app/src" folder. I run the following command from the folder above "app/src", let's call it root.

dart --package-root=app/packages/ app/packages/web_ui/dwc.dart --out tmp app/src/testapp.html

I send the output to a tmp folder in that root folder. The problem is that evey time I compile the app, the paths in script element have "../app/src" prepended to the path. So instead of having a

"packages/browser/dart.js" path I end up with "../app/src/packages/browser/dart.js". Is there a way to configure this and avoid getting this "app/src" prefixes.


Solution

  • Ok, I haven't found a solution to my problem using the dart tools configuration so I had to use the old friend - sed.

    sed "s/../app/src/packages/packages/g" ${OUT_DIR}/test.html > ${OUT_DIR_SERVER}/test.html