-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
131 lines (110 loc) · 2.28 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
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
PATH := node_modules/.bin:$(PATH)
SHELL := /bin/bash
.DEFAULT_GOAL := all
.PHONY: all clean deps help installIfNot
# Arguments
mode := prod
quiet := false
##
## Commands
##
all: clean deps dist
dist: dist/Private.js dist/Public.js
$(call action, "DONE")
watch:
$(call action, "Watching")
@ livereload dist/ \
& chokidar 'src/**' --initial --silent \
-c 'make -s dist mode=dev'
ifeq ($(mode), dev)
cache: dist/Private.bundle.js dist/Private.elm.js dist/Public.bundle.js dist/Public.elm.js
endif
clean:
@ rm -rf dist elm-stuff node_modules
$(call action, "Cleaned")
distclean:
@ rm -rf dist
$(call action, "Cleaned dist")
deps:
$(call action, "Installing...")
@ npm i
##
## Sources
##
elmSource := src/%.elm
allElmSources := src/*.elm
jsSource := src/%.js
allJsSources := src/*.js
mainFile := dist/%.js
elmOutput := dist/%.elm.js
bundle := dist/%.bundle.js
debug := dist/%.html
##
## Files dependencies & build
##
$(mainFile): $(elmOutput) $(bundle)
$(call stl, $*, "Concatenating")
ifeq ($(mode), prod)
@ uglifyjs $^ -mc 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9"' -o $@
else
@ cat $^ > $@
endif
$(elmOutput): $(elmSource) $(allElmSources)
$(call stl, $*, "Compiling")
ifeq ($(mode), prod)
@ ./bin/elm make $< --optimize --output=$@
else
@ ./bin/elm make $< --output=$@
endif
$(bundle): $(jsSource) $(allJsSources)
$(call stl, $*, "Bundling")
@ browserify $< -o $@
##
## Help & Formatting
##
help:
$(call action, "Build the front")
$(call help, "dist ","build files for production")
$(call help, "debug ","build files for debug")
@ echo ""
$(call help, "clean ","remove temporary files")
$(call help, "watch ","watch & compile files")
$(call help, "deps ","install dependencies")
$(call help, "help ","this")
@ echo ""
@ echo ""
@ echo " *defaults : quiet=false mode=prod"
@ echo ""
ifneq ($(quiet), true)
define stl
@ echo ""
@ tput setaf 4
@ tput bold
@ echo -n " :"
@ printf "%-.10s" "$1 "
@ echo -n ": "
@ tput setaf 7
@ echo -n "$2"
@ tput sgr0
endef
endif
define action
@ echo ""
@ tput setaf 4
@ tput bold
@ echo -n " : "
@ tput setaf 7
@ echo -n $1
@ tput sgr0
@ echo ""
endef
define help
@ echo ""
@ echo -n " > "
@ tput bold
@ tput setaf 6
@ echo -n $1
@ tput sgr0
@ echo -n " : "
@ echo -n $2
endef