aboutsummaryrefslogtreecommitdiff
path: root/makefile
blob: e955a3e0856e048899a66113b8feb59162edf550 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
ESFLAGS = --target=esnext --format=esm
.PHONY: watch-script watch-style clean all

all: deploy/fastbangs deploy/fastbangs.yaml

deploy/fastbangs.yaml: fastbangs.yaml
	cp --no-clobber $< $@; true
deploy/fastbangs: $(shell find src -name '*.hs') build/bundle.js build/index.html build/style.css
	stack install --local-bin-path deploy

build/index.html: frontend/index.html
	cp $< $@
build/bundle.js: build-dir $(shell find frontend -name '*.ts') frontend/fuzzysort.js
	esbuild frontend/main.ts --bundle --outfile=build/bundle.js $(ESFLAGS)
build/style.css: build-dir frontend/style.sass
	sassc $< $@

frontend/fuzzysort.js:
	curl -s 'https://cdn.jsdelivr.net/npm/fuzzysort@2.0.4/fuzzysort.min.js' -o $@

watch-script: deploy-dir frontend/fuzzysort.js
	esbuild frontend/main.ts --bundle --outfile=deploy/bundle.js $(ESFLAGS) --watch
watch-style: deploy-dir
	while true; do make deploy/style.css; inotifywait -e modify -e move frontend/style.sass; done

deploy.zip: all
	zip deploy.zip -r deploy

clean:
	stack clean --full
	rm -f deploy.zip
	rm -f frontend/fuzzysort.js
	rm -rf build/*
	# This leaves the deploy directory, which is intentional, as it may contain
	# user data