Created
January 22, 2020 09:18
-
-
Save ngsctt/954e7b6ea6051b874afcd098a11c07d3 to your computer and use it in GitHub Desktop.
Makefile for simple pug-based templating projects
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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