Search code examples
javascripthaxeopenfl

embedding .js code using openfl


I'm integrating an external JS library (timbre.js) into a Haxe / OpenFL project. Right now I'm just injecting calls to the library using the untyped keyword, like this:

untyped T("sin").play();

then I build the html5 ... but I have to insert this line manually into index.html, before the line that embeds the .js file created by openfl:

<script type="text/javascript" src="./lib/timbre.js"></script>

I would have guessed that there's a way to have openfl create this line automatically by some tag in the project.xml file, but I've failed to discover a way of doing this. Or would it be something in Main.hx itself?


Solution

  • You can override the index.html template in your project.xml file.

    Something like: <template path="custom_index.html" rename="index.html" />

    The template file is here: openfl/templates/html5/template/index.html Copy it to your project folder and edit it.

    Here is the full documentation In the Additional tags section.