-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
75 lines (68 loc) · 1.85 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
75
WEBPACK := $(PWD)/node_modules/.bin/webpack
WEBPACK_SERVER := $(PWD)/node_modules/.bin/webpack serve
.PHONY: deps
deps: node_modules
node_modules: package.json yarn.lock
@yarn install
@touch $@
.DEFAULT_GOAL := serve
## Serve site at http://localhost:3000 with hot reloading
.PHONY: serve
serve: deps
@$(WEBPACK_SERVER) --config webpack/dev.js
## Build site for production use
.PHONY: build
build: deps
@echo "Building front-end"
@rm -rf site/*
@NODE_ENV=production $(WEBPACK) --config webpack/prod.js
@echo "Front-end built!"
define primary
\033[38;2;166;204;112;1m$(1)\033[0m
endef
define title
\033[38;2;255;204;102m$(1)\033[0m\n
endef
## List available commands
.PHONY: help
help:
@printf "$(call primary,spa-starter)\n"
@printf "A starter template for single page applications (SPA) using Make\n\n"
@printf "$(call title,USAGE)"
@printf " make <SUBCOMMAND>\n\n"
@printf "$(call title,SUBCOMMANDS)"
@awk '{ \
line = $$0; \
while((n = index(line, "http")) > 0) { \
if (match(line, "https?://[^ ]+")) { \
url = substr(line, RSTART, RLENGTH); \
sub(url, "\033[38;2;119;168;217m"url"\033[0m", $$0); \
line = substr(line, n + RLENGTH); \
} else {\
break; \
} \
}\
\
if ($$0 ~ /^.PHONY: [a-zA-Z0-9]+$$/) { \
helpCommand = substr($$0, index($$0, ":") + 2); \
if (helpMessage) { \
printf " $(call primary,%-8s)%s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^[a-zA-Z\-\_0-9.]+:/) { \
helpCommand = substr($$0, 0, index($$0, ":")); \
if (helpMessage) { \
printf " $(call primary,%-8s)%s\n", \
helpCommand, helpMessage; \
helpMessage = ""; \
} \
} else if ($$0 ~ /^##/) { \
if (helpMessage) { \
helpMessage = helpMessage "\n " substr($$0, 3); \
} else { \
helpMessage = substr($$0, 3); \
} \
} \
}' \
$(MAKEFILE_LIST)