cerrado @ a47effe083d70cae7f039ff207087447a7a82ee0

ref: Refactor makefile

Now the makefile file takes into account the source folder for
temaplating and scss, which means it will not regeneratem them every
time you run "make" or "make run". This speeds up local development
iterations.
 1diff --git a/Makefile b/Makefile
 2index 068f872f4466fcf2cf7cacddb0a6dc17c0e22241..17e424db62b5ef0e9004443ef74860eda86f84ce 100644
 3--- a/Makefile
 4+++ b/Makefile
 5@@ -1,7 +1,16 @@
 6-SLUG ?= $(shell git rev-parse --short HEAD)
 7-LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(SLUG)' -s -w"
 8+GIT_COMMIT ?= $(shell git rev-parse --short HEAD)
 9+LDFLAGS := "-X 'git.gabrielgio.me/cerrado/templates.Slug=.$(GIT_COMMIT)' -s -w"
10+
11+TEMPLATES_DIR := templates
12+TEMPLATES := $(wildcard $(TEMPLATES_DIR)/*.qtpl)
13+GO_TEMPLATES_FILES := $(TEMPLATES:.qtpl=.qtpl.go)
14+
15+SASS_DIR := scss
16+CSS_DIR := static
17+OUTPUT_CSS := $(CSS_DIR)/main.$(GIT_COMMIT).css
18+SASS_FILES := $(wildcard $(SASS_DIR)/*.scss)
19 
20-build: sass-slug tmpl
21+build: sass tmpl
22 	go build \
23 		-ldflags=$(LDFLAGS) \
24 		-o bin/cerrado
25@@ -12,20 +21,18 @@
26 test:
27 	go test -v --tags=unit ./...
28 
29-# this is meant for "prod" build
30-sass-slug:
31-	mkdir -p static
32-	sassc \
33-		--style compressed \
34-		-I scss scss/main.scss static/main.$(SLUG).css
35+sass: $(OUTPUT_CSS)
36+
37+$(OUTPUT_CSS): $(SASS_FILES)
38+	@mkdir -p $(CSS_DIR)
39+	sassc $(SASS_DIR)/main.scss $(OUTPUT_CSS)
40+
41+tmpl: $(GO_TEMPLATES_FILES)
42 
43-sass:
44-	mkdir -p static
45-	sassc \
46-		-I scss scss/main.scss static/main.css
47+$(TEMPLATES_DIR)/%.qtpl.go: $(TEMPLATES_DIR)/%.qtpl
48+	qtc $(TEMPLATES_DIR)/$*.qtpl
49 
50-tmpl:
51-	cd ./templates && \
52-	qtc *
53+clean:
54+	rm -f $(OUTPUT_CSS)
55 
56-.PHONY: sass
57+.PHONY: sass tmpl