personal-site/Makefile -rw-r--r-- 2.3 KiB View raw
                                                                                
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
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Copyright (C) 2019 Andrew Zah

# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU Affero General Public License as published
# by the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
# 
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
# GNU Affero General Public License for more details.
# 
# You should have received a copy of the GNU Affero General Public License
# along with this program.  If not, see <http://www.gnu.org/licenses/>.

# Use a TMP dir because the last step would be $(DIST_DIR)/%: $(DIST_DIR)/%
# otherwise. Obviously this is a circular dependency, but the step uses the
# targets to go through asset-manifest and append the hash.

TMP_DIR             := tmp
SRC_DIR             := static
JS_DIR              := $(SRC_DIR)/js
MIN_JS_DIR          := $(SRC_DIR)/js/min

STATIC_MIN_JS_FILES := $(wildcard $(SRC_DIR)/js/min/*)
PUBLIC_MIN_JS_FILES := $(public/js/min/*)

JS_FILES            := $(wildcard $(JS_DIR)/*.js)
MIN_JS_FILES        := ${patsubst $(JS_DIR)/%,$(MIN_JS_DIR)/%,$(JS_FILES:.js=.min.js) }
PUBLIC_FILES        := $(wildcard public/*)
CONTENT_FILES       := $(wildcard public/*) $(wildcard content/*) $(wildcard templates/*)

JS_TARGET           := $(JS_DIR)/bundle.js

.PHONY: all
all: js
js: uglifyjs bundlejs
uglifyjs: $(MIN_JS_FILES)
bundlejs: $(JS_TARGET)
removebundlejs:
	-@rm -rf $(JS_TARGET)
touchjs:
	touch $(wildcard $(JS_DIR)/*)
touchc:
	touch $(wildcard $(SRC_DIR)/stylesheets/*)
delmin:
	rm -rf $(MIN_JS_DIR)
	rm -rf $(PUBLIC_MIN_JS_DIR)

build: $(CONTENT_FILES)
	zola build

static: build
	rsync -arv public/* ../website-static-assets

up:
	docker-compose down
	find . -type f -exec chmod 644 {} +
	find . -type d -exec chmod 755 {} +
	zola build
	docker-compose build
	docker-compose up

push:
	git push origin master
	git push github master
	git push self master

deploy:
	git submodule update --recursive --remote
	zola build
	docker-compose build
	docker push andrewzah/personal_site:latest

$(MIN_JS_DIR)/%.min.js: $(JS_DIR)/%.js
	uglifyjs -o $@ $<
	@echo "Minified JS ("$<")"

$(JS_TARGET): $(MIN_JS_FILES)
	@cat $^ > $@
	@echo "Made bundle! "$@": \n ->"$^