Delete www directory before compilation

Hej !

When I work with PHP target, I want to delete the output directory before compilation in order to have fresh files only without some old files.
I’ve written a little macro who do that and I call it in .hxml using --macro.
But It works half a time since sometimes it seems that compilation occurs when deletion hasn’t finished yet…
It there a way to avoid that please or do that another way ?

Thanks

try this hxml:

--cmd your_delete_script.bat
#or
--macro your_delete_macro
--next
#your compilation parameters
2 Likes

Thanks it seems to work !

And BTW what is the explanation that without --next it fails sometimes ?
Compilation isn’t waiting all macro is done before generating ? Antoher thread ?

Compiler has to load and type some code to run your macro.
This could potentially affect further compilation because of some macro contexts being shared across the compilation.

1 Like

Hej @RealyUniqueName !

It works well but in VSCode it does’nt recognize anymore a “target section” (#if php for example), it will “blur” it, I don’t know if it clear enough ?

It’s not clear enough :slight_smile:

Let’s say I’ve a .hxml like that :

-lib ftk
--macro ftk.macro.Compiler.deleteRegexFiles( "www", "(app)([\\.0-9]*)(\\.min)*\\.js" )

--next

common.hxml

--macro ftk.macro.Compiler.setOutputFilenameByVersion()
--macro ftk.macro.Compiler.alignCSSVersion( "www", "(app)([\\.0-9]*)(\\.min)*\\.css" )
#--macro ftk.macro.Compiler.runTerserAfterCompilation()

Client

-js www/app.js

So my target here is js right ? But in VSCode all the js parts are grey/blured as if it is not this target…

AFAIR vscode picks the first target of an hxml, which is the one before the first --next.
You can extract your js section into a separate hxml and choose it in vscode for completion:

Thanks for your answer Aleksandr.
So it means I have to switch from one to the other .hxml in order to clean up my files and then compile my projet right ?
Maybe VSCode plugin could detect that there is no output in the first part and not take in account this one and go the the “next” ?

I guess you have to submit a feature request to vshaxe repo for that.

Hej Aleksandr,

I’ve submitted that but Multiple "targets" in same .hxml file · Issue #466 · vshaxe/vshaxe · GitHub

Ah, right. I forgot about that.
Well, you can submit an issue to the compiler repo, but I doubt we’ll have time to resolve it anytime soon.
I guess it should be possible to configure vscode to use one hxml for completion and another hxml for building.

Ok thanks Aleksandr !

It’s not something pressing but if it could be done one day I think it could be good.

Regards

In fact Aleksandr, I don’t know what to write as issue in haxe github since it’s for me something likend with vscode, can you help me what to write about exactly please ? You should be more precise than me…

Aleksandr,

What is the root problem in haxe that does that vshaxe works like that please ?
I want to write a github haxe issue but If I write “Hi guys, there is an issue that do that if there is no output target specified in .hxml file, so vshaxe will fade the target code”, the guys will close the issue before ending reading.
I’m not lazy, I don’t want you to be my secretary, but I just want to know how to write a good issue since as I said I don’t know why Haxe is the problem here and not vshaxe plugin you know ?

Regards,

No problem. Compiler just picks the first configuration available.