Makefile 1.56 KB
Newer Older
1
PACKAGE_NAME=rebuilderd-website
2
3
4
5
6
7
8
9
10

# Tools

SASS ?= sass
YARN ?= yarn

# Variables

PORT ?= 9966
11
HOST ?= localhost
12
13
14
VERSION ?= $(shell git describe --tags --always --dirty --match=v* 2>/dev/null | sed 's/^v//' || \
			cat $(CURDIR)/.version 2> /dev/null || echo 0.0.0-unreleased)

Jelle van der Waa's avatar
Jelle van der Waa committed
15
all: vendor
16
17
18
19

# Watchers

.PHONY: sass-watcher
20
sass-watcher: vendor
21
22
23
	$(SASS) --watch src/style.scss:public/bundle.css

.PHONY: js-watcher
24
js-watcher: vendor
25
	# TODO: yarn run doesn't work..
26
	./node_modules/.bin/budo src/index.js:bundle.js --dir public --host $(HOST) --port $(PORT) --live -- -t babelify
27
28
29
30
31


# Dist

.PHONY: dist
32
dist: vendor
33
34
	@mkdir -p "dist/${PACKAGE_NAME}-${VERSION}"
	cp -avf public/index.html "dist/${PACKAGE_NAME}-${VERSION}/index.html"
35
	# TODO: cache-invalidation with version string replaced in html file
36
	cp -Lvf public/favicon.ico public/*.svg -t "dist/${PACKAGE_NAME}-${VERSION}/"
37
	$(SASS) -t compressed src/style.scss "dist/${PACKAGE_NAME}-${VERSION}/bundle.css"
38
	$(YARN) run -s browserify -t babelify src/index.js | $(YARN) run -s terser --compress --mangle > "dist/${PACKAGE_NAME}-${VERSION}/bundle.js"
39
40
41
42
43
44
	cd dist && tar --owner=0 --group=0 -czvf ${PACKAGE_NAME}-${VERSION}.tar.gz "${PACKAGE_NAME}-${VERSION}"


# Yarn

.PHONY: vendor
45
vendor: submodule .yarninstall
46
47
48
49
50

.yarninstall: package.json
	@$(YARN) install --silent
	@touch $@

51
52
53
54
.PHONY:
submodule:
	git submodule update --init --recursive
	make -C .external/archlinux-common-style
55

56
57
58
59
.PHONY:
distsize:
	@du -s "dist/${PACKAGE_NAME}-${VERSION}"

60
61
62
63
64
65
.PHONY:
clean:
	$(YARN) cache clean
	@rm -rf dist
	@rm -rf node_modules
	@rm -f .yarninstall