Skip to content

Instantly share code, notes, and snippets.

@ngsctt
Created January 22, 2020 09:18
Show Gist options
  • Save ngsctt/954e7b6ea6051b874afcd098a11c07d3 to your computer and use it in GitHub Desktop.
Save ngsctt/954e7b6ea6051b874afcd098a11c07d3 to your computer and use it in GitHub Desktop.
Makefile for simple pug-based templating projects
SHELL := /bin/zsh
DEST ?= print
PORT ?= 8888
WATCH ?= *.pug, *.less
BUILD ?= pug --out $(DEST) [^_]*.pug
includes := $(shell cat _include)
build: copy convert
makedir: $(DEST)
$(DEST):
if [ ! -d $(DEST) ]; then mkdir $(DEST); fi
$(includes): makedir
if [ -f $@ ]; then cp $@ $(DEST)/$@; fi
copy: $(includes)
convert:
$(BUILD)
serve: copy convert
npx light-server --serve $(DEST) --port $(PORT) --watchexp '$(WATCH) # $(SHELL) -c "$(BUILD)" # reload'
clean:
rm -rf $(DEST)
run:
trap 'trap - SIGINT SIGTERM ERR; $(MAKE) clean; exit 0' SIGINT SIGTERM ERR; $(MAKE) serve;
.PHONY: build makedir copy convert serve clean run
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment