In Haxe, there is a thing known as a build file. This file is often used in your project for autocomplete/IntelliSense (this is when suggestions come up in your code as you type) and to determine what/how your code should be compiled in Haxe. This is the best way to set up how to handle your Haxe project. For example, I have a build file from a project of mine. Let’s look at the example below.

# Haxe Library
-lib LunaTea
-cp src
# JS Version
-D js-es=6
# Enable/Disable console.log — tracing with the below line
# –no-traces
-dce full
# Static Code Analysis For Removing Unnecessary Code
-D analyzer-optimize
# Haxe Source Map
# –no-inline
# –no-opt
# -D keep_inline_positions
# RM Version for Conditional Compilation
# -D compileMV
# Note you can call an hxml file inside an hxml file for build purposes.
# For Compiling Separate JavaScript Files
# –macro macros.MacroTools.includeJsLib("./src/Params.js")
# –main Main
–cmd 'npx napkin'
–cmd haxe -D gamePath=../games/LunaTechsMZ –run CleanJs
view raw compile.hxml hosted with ❤ by GitHub

Now with that said, let me dive into the example, starting with flags. For a more in-depth look at flags, you can find them here and here, these are all the flags that you can possibly send to the Haxe compiler when working on your project.


Flags are a common concept in programming. They are used to send instructions to the compiler in a concise way. Instead of typing out complex commands, we can send flags such as “-D MV” to get the job done. After all the computer needs to know what we want. In our case, we use the Haxe build file (HXML) to do several things.

  • Set the source directory (-cp)
  • Set the compilation target (-D compileMV)
  • How to optimize our code (-dce)
  • What libraries to compile our code with (-lib)
  • What Haxe target to use (Python, JS, CPP, etc)
  • Whether to use source maps
  • and much more!

These are just some of the flags we use. There are others like we mentioned above, but these are the most common. But, there’s, even more, you can do with these files.

Build On Build Files

If you noticed in the example, we actually have other build files referenced in the main file. THis is because build files can run other build files when the code is compiled at the end. So, if you need special configuration for one of your builds, that can be it’s own file. The great thing about these files is that they allow us to be flexible when creating the configuration for our final product. We can have test builds, platform specific builds, and of course production builds as well. With that said, let’s get into some final tips about build files.


Haxe uses these build files to create the autocomplete for your entire project. As of right now, there’s only one build file that can be used for this at a time. So it can be useful to create a build file just to have autocomplete within the project if you have multiple different types of builds and configurations for each build.

Another tip is that you can run terminal commands in your Haxe files. We do this at the end of our example. Additionally, we can run these commands with flags as well.

Closing Remarks

That’s all for now as a basic overview on build files. There’s more to come as we get into some more Haxe speicifics, such as conditional compilation which was used in our example above. I hope this helps with your own game!

%d bloggers like this: