Automate the Boring Stuff with ...
Do you recognize this pattern?
- CMD + TAB > Terminal
- Cursor + UP
- CMD + TAB > Browser
- CMD + R
- CMD + TAB > Sublime Text
- Change files
As a programmer you are looking for patterns, so you can put them a function and use that function over and over again.
The same thing applies to compiling/refreshing/updating code.
If you do a lot of the same tasks over and over and over again, you should read this example. Probably for the more experienced programmer, but I guess everybody can enjoy automation.
This example is not about programming or Haxe/NodeJs. But about the tedious task around programming.
This example is the same as the first example: a simple "Hello world"! Read more about "hello world"
In this example we will build the Haxe with Grunt and let Grunt "watch" the files for changes. If there are any changes, Grunt will rebuild.
You can achieve he same thing with Nodemon. Nodemon will restart Node, when the file changes. In our case it will watch one file, but when it changes it will restart the server.
Everything changed a little by a suggestion from Clark Jones!
I now would suggest you use NPM for automation. And visit the second example I wrote (with a big help from Clark). It uses NPM for watch, livereload, restart Nodemon and one terminal window! Check out the code folder
Why use a task runner? In one word: automation. The less work you have to do when performing repetitive tasks like minification, compilation, unit testing, linting, etc, the easier your job becomes. After you've configured it through a Gruntfile, a task runner can do most of that mundane work for you—and your team—with basically zero effort.
I will not get into the Grunt vs Gulp discussion. Because I like Grunt I will explain Grunt! (And its fun to say the word Grunt as many times you can)
It absolutely doesn't mean Gulp is bad, I just leave that example to someone else!