A simple recipe to use grunt watch to setup simple autorun workflow while developing any type of project
It is great to have a tool that watches changes and reruns code (like tests or server code etc) as you are saving your files. This idea here of course works great with any Node project but hey, even if you are not coding in Node (or even in language other than JS), you can still use this idea, it's very generic and will work for just about any type of project if you just set this basic setup once.
While there are many approaches to doing this depending on the project type (like webpack's watch which is super-powerful for web projects, nodemon for server restart cases, chokidar etc), my current favorite for a generic method that will work with any type of project is based on grunt-watch. So read on!
I setup this simple repository with a simple readme guide on how to do this.
https://github.com/binodpanta/node-examples/tree/master/gruntwatch
I think it will save you a lot of time when working on NodeJS projects. Even if you don't use Grunt for your actual development cycle, having this setup alone is worth the few minutes it takes to do this, it's extremely simple, almost too simple to not use.
So take 5 minutes and set this up in your Node project before you write any or much code and you will save yourself a lot of time down the road.
I use this recipe when I have very little time on a project, and I get up and running in minutes.
Soon I will try to publish how to add Mocha and NYC to this setup so you can easily rerun unit tests and get updated code coverage as you save your files in an editor! Isn't that neat!
While there are many approaches to doing this depending on the project type (like webpack's watch which is super-powerful for web projects, nodemon for server restart cases, chokidar etc), my current favorite for a generic method that will work with any type of project is based on grunt-watch. So read on!
I setup this simple repository with a simple readme guide on how to do this.
https://github.com/binodpanta/node-examples/tree/master/gruntwatch
I think it will save you a lot of time when working on NodeJS projects. Even if you don't use Grunt for your actual development cycle, having this setup alone is worth the few minutes it takes to do this, it's extremely simple, almost too simple to not use.
So take 5 minutes and set this up in your Node project before you write any or much code and you will save yourself a lot of time down the road.
I use this recipe when I have very little time on a project, and I get up and running in minutes.
Soon I will try to publish how to add Mocha and NYC to this setup so you can easily rerun unit tests and get updated code coverage as you save your files in an editor! Isn't that neat!
Comments
Post a Comment