lib/%: src/%
mkdir -p $(dir $@)
babel $
Just look at all those magic things. The percent signs! $Well, I know they are not magic ;). But why would I want them when I can actually use normal names like "deps"/"entries" and "target"?It gets substantially worse as we go down the rabbit whole. Where webpack can easily walk the entire dependency tree by itself, we have to invoke
src_files := $(shell find src/ -name '*.js')
Where we can use same webpack to seamlessly output the resulting file into an output directory, we need to do the (very unintuitive) pattern substitution: transpiled_files := $(patsubst src/%,lib/%,$(src_files))
or even flow_files := $(patsubst %.js,%.js.flow,$(transpiled_files))
And when we want to watch for changes? Well, we need an external program anyway. $ yarn global add watch
$ watch make src/
The art of Makefiles is often lost for good reasons: because Makefile don't really cut it anymore.