This repository has been archived by the owner on Nov 17, 2020. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathMakefile
62 lines (52 loc) · 1.57 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
browserify = $(shell npm bin)/browserify
node_static = $(shell npm bin)/static
uglifyjs = $(shell npm bin)/uglifyjs
surge = $(shell npm bin)/surge
json = $(shell npm bin)/json
dependencies = $(shell set -o pipefail && cat package.json | $(json) dependencies | $(json) -ka)
prepend-r = sed 's/\([^ ]*\)/-r \1/g' # prepending '-r' to each dependency
prepend-x = sed 's/\([^ ]*\)/-x \1/g' # prepending '-x' to each dependency
.PHONY: dist
dist:
node template.js
make dist/js
make dist/css/common.css
cp src/index.html src/remote.html dist
cp -r gifs dist
cp CNAME dist
dist/js: dist/js/babel-polyfill.js dist/js/common.js dist/js/main.js dist/js/remote.js
dist/js/babel-polyfill.js: node_modules/babel/node_modules/babel-core/browser-polyfill.min.js Makefile
mkdir -p $(@D)
cp node_modules/babel/node_modules/babel-core/browser-polyfill.min.js $@
dist/js/common.js: package.json Makefile
mkdir -p $(@D)
echo $(dependencies) \
| $(prepend-r) \
| xargs $(browserify) \
| $(uglifyjs) --mangle \
> $@
dist/js/main.js: src/*.js src/**/*.js Makefile
mkdir -p $(@D)
echo $(dependencies) \
| $(prepend-x) \
| xargs $(browserify) src/main.js -t babelify \
> $@
dist/js/remote.js: src/*.js src/**/*.js Makefile
mkdir -p $(@D)
echo $(dependencies) \
| $(prepend-x) \
| xargs $(browserify) src/remote.js -t babelify \
> $@
dist/css/common.css: src/*.css Makefile
mkdir -p $(@D)
cp src/common.css $@
.PHONY: serve
serve:
@echo serving at http://localhost:8000
@$(node_static) . -p 8000 -z > /dev/null
.PHONY: deploy
deploy:
rm -rf dist
mkdir -p dist
$(MAKE)
$(surge) dist