Haxe-watchify is an automatic build tool for your Haxe and OpenFL projects

View project on GitHub

Haxe-watchify

Haxe-watchify is a command line daemon that check any files changes in your Haxe project and run the build automatically in background. The files extensions watched are:

  • . hx
  • . hxml
  • . nmml
  • . jpg
  • . jpeg
  • . gif
  • . png
  • . xml
  • . json
  • . css
  • . php
  • . html
  • . yml
  • . txt
  • . ogg
  • . wav
  • . mp3
  • . mp4
  • . m4a
  • . ttf
  • . otf
Currently haxe-watchify is compatible with Haxe and OpenFL projects.

How to install

In order to install haxe-watchify you just need to install from NPM as global package: npm install haxe-watchify -g After that you'll be able to use haxe-watchify in any of your Haxe projects.

How to use haxe-watchify

Using haxe-watchify is really simple, you can approach in different ways:

command-line

First of all navigate to the project folder, then start haxe-watchify via command-line using: haxe-watchify --program haxe --hxml build.hxml In this case, haxe-watchify is going to use the hxml file to build your project, so anytime you will change an Haxe file, haxe-watchify will rebuild your Haxe project in background. These are the other parameters that the command-line accepts: Usage: haxe-watchify [options]

Options:
   -h, --help      output usage information
   -V, --version   output the version number
   --program       set the tool to build your project, the parameter could be 'haxe' or 'openfl'. The defualt value is 'haxe'
   --hxml          set the hxml file to use for the build
   --compiler      set 'server' to use the completion server. The default value is 'local'
   --port          set the port number. By default port is 6000
   --buildType     set the command to use on OpenFL targets: build or test. The defualt value is 'build'
   --src           set the Haxe classes source folder. The default value is the folder where you run haxe-watchify
   --livereload    set the local folder where the server will point
   --platforms     set the platform to build OpenFL project separated by , (e.g.: flash,html5)

build an Haxe project

To build an Haxe project via command line you just need to type: haxe-watchify --program haxe --hxml build.hxml if you want use the completion server just add this parameter and automatically haxe-watchify will start haxe in server mode on the port specified with the -port argument: haxe-watchify --program haxe --hxml build.hxml --compiler server --port 6789 By default if the port it's not specified the server will start on port 6000 If you don't specify the compiler, by default haxe-watchify will use haxe in normal mode.

haxe-watchify doesn't accept any other arguments for Haxe, so if you need to specify build arguments please use the .hxml file or the hx-watch.json file.

build an OpenFL project

This is the template structure to compile your OpenFL project: {
  "build": {
    "program" : "openfl",
    "platforms" : ["flash", "tizen", "html5"]
  }
}
Last but not least on OpenFL you can decide if run the build with the build or test command in this way: {
  "build": {
     "program" : "openfl",
     "buildType" : "test", //set test or build as parameter
     "src" : "Source",
     "platforms" : ["flash", "tizen", "html5"]
   }
}

Live Reload

From version 1.2.1, Haxe-watchify would be able to start a server with live reload feature on any browser window that is open at the url http://localhost:35729/ or from another device replacing localhost with the IP of your machine.
So anytime you'll change in the export folder any class or resource file automatically haxe-watchify will update your browser window as you can see in this video:

You can use the live reload option via command-line or in the configuration file simply setting the project output folder: {
  "build": {
    "program" : "openfl",
    "buildType" : "test", //set test or build as parameter
    "src" : "Source",
    "livereload" : "Export",
    "platforms" : ["flash", "tizen", "html5"]
  }
}
So the output folder will be the root folder of your server and if you want to open the html5 version created by OpenFL, for instance, you'll type inside your browser http://localhost:35729/html5/index.html. This feature works with HTML and Flash targets generated by Haxe or OpenFL.
Live reload is exclusively watching the folder you've specified in the configuration file, instead haxe-watchify is watching the folder you've specified in the src parameter or otherwise in the project root but always excluding the folders specified in the live reload parameter.
Obviously the live reload feature works with any browser of any device, simulators or emulators.

Web Monitor

From version 1.3.0, Haxe-watchify introduces a web monitor that reproduce the command line output directly in a web page.
This feature could help you when you want to extend your working area but you don't have a second monitor, or to share with your fellows the building process of your Haxe project.
When the server is started you can see the monitor at this page: http://localhost:30000/monitor.html or from another device substituting localhost with your IP machine.
This is a quick video showing the web monitor functionality:

All you need to do in order to start the monitor server is set the monitor property with the value web.
{
  "build": {
    "program" : "openfl",
    "buildType" : "test", //set test or build as parameter
    "src" : "Source",
    "monitor" : "web",
    "platforms" : ["flash", "tizen", "html5"]
  }
}

If this feature will be used and requested by the community I'll be more than happy to create the mobile applications for iOS, Android and WP8.

Notes for Windows users

Haxe-watchify requires Python 2.7.x to be installed in your machine in order to work.

Support or Contact

To report a bug please use the issues section on Github.

You can also check the project roadmap for the tool and the website.

Do you love to support the project? Check out our store!

if you want collaborate to the project or if you'd like a new feature, please drop me a line!