[Resolved] Haxe/JS Extern include src file

Hi,

I’m trying to use an external js API, using an intermediary js file and an extern.

I’ve got this working - but my issue is that I’d like to copy my intermediary JS file into my bin folder when I build, rather than manually. Or, add it into my my main game JS file…

Is there a way of doing this? (Bonus points if you can tell me how to do it in atom.io too)

I think you can use the <dependency path"your/intermediary.js" /> node in your project.xml,
although that’ll copy it to the bin/lib folder not bin.

Or you can use a post build commands:

<postbuild command="cp your/intermediary.js Export/html/debug/bin/" if="debug" />
<postbuild command="cp your/intermediary.js Export/html/release/bin/" if="release" />
<postbuild command="cp your/intermediary.js Export/html/final/bin/" if="final" />

note that post script commands can also be coded in haxe <postbuild haxe="PostBuild.hx" />

adding the dependancy path adds it to the HTML file, but doesn’t copy the file for you.

I’ve tried the postbuild stuff, but haven’t got it working (yet.)

I presume that the path needs to be the full path from the hxproj file?

I use the template method for that and modify the index.html source file to add in my js main script.

project.xml:

<template path="Templates/js/customeJS.js" rename="js/customeJS.js" if="html5" />```

**index.html:**
```<script type="text/javascript" src="js/customeJS.js"></script>```

thanks @balk I don’t seem to be able to get template to copy the file into the directory…

I’m also fairly certain that when using atom.io the hxproj isn’t called - because that also isn’t copying the file

and also
<postbuild open="/Users/Me/Folder1/Folder2">

doesn’t open the folder

It doesn’t appear that either option works from the command line either

euh… tag template copy automaticly your file into export|bin folder like asset tag.
I don’t know atom.io so i can’t see exactly what you are talking about :pensive:

@charlie_says which file are you editing? you need to edit your project.xml file,
I don’t think atom even use the hxproj file.

hi @ibilon,

in my template xml I’ve got

<dependency name="spil/Wrapper.js" />

which does correctly update the html. (but doesn’t copy the js file across, or include it in the output JS)

I’ve tried:

<template path="src/js/Wrapper.js" rename="bin/html5/bin/js/Wrapper.js" if="html5" />

Doesn’t copy the file across.

If you’ve got any ideas I’d be really grateful, because doing it manually is proving a bit…

I think the thing I find strange is that it also doesn’t do anything when I build from the command line… (So, I guess something must be wrong with my xml)

The system copy at the source of your project. So you don’t have to add “bin/html5/bin”. Just “js/Wrapper.js” is correct.
<template path="src/js/Wrapper.js" rename="js/Wrapper.js" if="html5" />

And…

…that worked!

Thanks @balk & @iblion for helping me out (especially as I probably should have been able to work that out.)