-
Notifications
You must be signed in to change notification settings - Fork 6
/
Makefile
74 lines (53 loc) · 1.96 KB
/
Makefile
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
PACKAGE_NAME=rebuilderd-website
# Tools
SASS ?= sass
YARN ?= yarn
# Variables
PORT ?= 9966
HOST ?= localhost
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)
ARCHLOGO = archlogo.8a05bc7f6cd1.svg
all: vendor
# Watchers
.PHONY: sass-watcher
sass-watcher: vendor
$(SASS) --watch src/style.scss:public/bundle.css
.PHONY: js-watcher
js-watcher: vendor
# TODO: yarn run doesn't work..
./node_modules/.bin/budo src/index.js:bundle.js --dir public --host $(HOST) --port $(PORT) --live -- -t babelify
# Dist
.PHONY: dist
dist: vendor
@mkdir -p "dist/${PACKAGE_NAME}-${VERSION}"
cp -avf public/index.html "dist/${PACKAGE_NAME}-${VERSION}/index.html"
svgcleaner public/${ARCHLOGO} "dist/${PACKAGE_NAME}-${VERSION}/archlogo-${VERSION}.svg"
cp -vf public/favicon.ico -t "dist/${PACKAGE_NAME}-${VERSION}/"
$(SASS) -t compressed src/style.scss "dist/${PACKAGE_NAME}-${VERSION}/bundle-${VERSION}.css"
$(YARN) run -s browserify -t babelify src/index.js | $(YARN) run -s terser --compress --mangle > "dist/${PACKAGE_NAME}-${VERSION}/bundle-${VERSION}.js"
# sed the version file in html
@sed -i 's/bundle.js/bundle-${VERSION}.js/' "dist/${PACKAGE_NAME}-${VERSION}/index.html"
@sed -i 's/bundle.css/bundle-${VERSION}.css/' "dist/${PACKAGE_NAME}-${VERSION}/index.html"
# sed the svg version in css
@sed -i 's/${ARCHLOGO}/archlogo-${VERSION}.svg/' "dist/${PACKAGE_NAME}-${VERSION}/bundle-${VERSION}.css"
cd dist && tar --owner=0 --group=0 -czvf ${PACKAGE_NAME}-${VERSION}.tar.gz "${PACKAGE_NAME}-${VERSION}"
# Yarn
.PHONY: vendor
vendor: submodule .yarninstall
.yarninstall: package.json
@$(YARN) install --silent
@touch $@
.PHONY:
submodule:
git submodule update --init --recursive
make -C .external/archlinux-common-style
.PHONY:
distsize:
@du -s "dist/${PACKAGE_NAME}-${VERSION}"
.PHONY:
clean:
$(YARN) cache clean
@rm -rf dist
@rm -rf node_modules
@rm -f .yarninstall