Makefiles for Web Projects

It seems everyone and their mom has a slick new build system designed to streamline the web development process.

These tools are great, but what about those small projects that don’t necessitate extra dependencies?

In comes Make. It’s ubiquitous. It’s simple. It’s self-documenting. It’s un-sexy.

Here is an example CSS and Javascript build system using a Makefile.

This example compiles Javascript and CSS dependencies into single minified files. It even watches your project folder for changes and compiles then automatically.

To use it, simply run make watch. Make some changes to your Javascript and they will be compiled automatically. Before deploying to production, run make optimize.

fswatch in a terminal window

This example assumes dependencies fswatch and yuicompressor are installed, but you could tailor it however you want. Both can be installed with Homebrew.

If you’re on GNU/Linux, inotifywatch provides similar functionality to fswatch.

More examples using Make:

 

Comments are closed.