News for hackers. Stuff that matters.
Re:Time for Makefiles to Make a Comeback by vortico on Tuesday September 05, 2017 @06:07AM (#15173800)
Interestingly enough, I tried using Makefiles for a web project yesterday, and it was a success.

    SOURCES = index.pug layout.pug style.styl main.coffee privacy.md
    OBJECTS = index.html style.css main.js privacy.html

    all: $(OBJECTS)

    watch:
    	http-server &
    	while true; do \
    		$(MAKE); \
    		inotifywait -qq $(SOURCES); \
    	done

    %.html: %.pug
    	pug -P $^

    %.css: %.styl
    	stylus $^

    %.js: %.coffee
    	coffee -c $^

    %.html: %.md
    	markdown $^ > $@

    clean:
    	rm -rfv $(OBJECTS)
This could be extended to produce an out-of-source build by using `-o "$(PUBLIC)"` on the command line generators, but I didn't need it for this project.
Re:Time for Makefiles to Make a Comeback by jgrahamc on Tuesday September 05, 2017 @07:04AM (#15174026)
Do you know about the ; style for rules that have only one line of commands? It helps reduce the number of tabs.

    %.html: %.pug ; pug -P $^
I find it super useful for compact Makefiles:

    %.html: %.pug    ; pug -P $^
    %.css:  %.styl   ; stylus $^
    %.js:   %.coffee ; coffee -c $^
    %.html: %.md     ; markdown $^ > $@
    clean: ; rm -rfv $(OBJECTS)
Also, worth making clean .PHONY since it's not a file.
Re:Time for Makefiles to Make a Comeback by Yaggo on Tuesday September 05, 2017 @11:23AM (#15176099)
Sure, that's the traditional way of doing things, and I like its simplicity and the fact that the 40 years old core concept is still so useful.

But most of us want to require() modules also in the browser, so you'll anyway need browserify or other bundler, which already have cross-platform watch mode & plugin ecosystem, and are expected to be run continously, and suddenly the Makefile feels rather redundant, especially with npm scripting.

Re:Time for Makefiles to Make a Comeback by GlennS on Tuesday September 05, 2017 @12:38PM (#15176817)
I'd recommend adding:

.PHONY: watch .PHONY: clean

In the appropriate places.