]>
Commit | Line | Data |
---|---|---|
1 | SHELL=/bin/bash | |
2 | ENV ?= dev | |
3 | export PATH := $(PATH):./node_modules/.bin | |
4 | ||
5 | SRC_DIR=js | |
6 | BUILD_DIR=build/js | |
7 | JSX_SRC= header_footer.jsx main.jsx signup.jsx signin.jsx otp.jsx poloniex.jsx password_reset.jsx change_password.jsx account.jsx balance.jsx | |
8 | JS_SRC= cookies.js app.js api.js | |
9 | STATIC_FILES= index.html style.css fontello.css | |
10 | STATIC_FILES+=$(addprefix fonts/, fontello.eot fontello.svg fontello.ttf fontello.woff fontello.woff2) | |
11 | JSX_OBJS=$(addprefix $(BUILD_DIR)/,$(JSX_SRC:.jsx=.js)) | |
12 | JS_OBJS=$(addprefix $(BUILD_DIR)/,$(JS_SRC)) | |
13 | ICONS=$(addprefix $(STATIC_BUILD_DIR)/icons/black/, $(notdir $(wildcard static/icons/black/*.svg))) | |
14 | ICONS+=$(addprefix $(STATIC_BUILD_DIR)/icons/color/, $(notdir $(wildcard static/icons/color/*.svg))) | |
15 | STATIC_BUILD_DIR=build/static | |
16 | ||
17 | install: | |
18 | node --version | |
19 | npm --version | |
20 | yarn --version | |
21 | yarn install | |
22 | ||
23 | static: $(STATIC_BUILD_DIR) $(STATIC_BUILD_DIR)/fonts js $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) $(ICONS) | |
24 | ||
25 | js: build/static/main.js | |
26 | ||
27 | $(STATIC_BUILD_DIR)/%: static/% | |
28 | cp $< $@ | |
29 | ||
30 | $(STATIC_BUILD_DIR): | |
31 | mkdir -p $(BUILD_DIR) | |
32 | mkdir -p $@ | |
33 | mkdir -p $@/icons/black | |
34 | mkdir -p $@/icons/color | |
35 | ||
36 | $(STATIC_BUILD_DIR)/fonts: | |
37 | mkdir -p $@ | |
38 | ||
39 | $(BUILD_DIR)/%.js: $(SRC_DIR)/%.jsx | |
40 | eslint --fix $< | |
41 | cp $< $@ | |
42 | ||
43 | $(BUILD_DIR)/%.js: $(SRC_DIR)/%.js | |
44 | eslint $< | |
45 | cp $< $@ | |
46 | ||
47 | $(STATIC_BUILD_DIR)/icons/black/%.svg: static/icons/black/%.svg | |
48 | cp $< $@ | |
49 | ||
50 | build/static/main.js: $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env | |
51 | browserify -t [ babelify --presets [ env react ] --plugins [ transform-class-properties ] ] \ | |
52 | -t [ localenvify --envfile env/$(ENV).env ] \ | |
53 | -t [ debowerify ] \ | |
54 | $(BUILD_DIR)/main.js -o $@ | |
55 | ||
56 | build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(ICONS) | |
57 | tar czf $@ --directory=$(dir $<) $(subst $(STATIC_BUILD_DIR)/,,$^) | |
58 | ||
59 | release: $(STATIC_BUILD_DIR) build/webapp.tar.gz | |
60 | ||
61 | clean: | |
62 | rm -rf build | |
63 | rm -rf node_modules | |
64 | ||
65 | ||
66 | FONT_DIR = ./static/fontello | |
67 | FONTELLO_HOST ?= http://fontello.com | |
68 | ||
69 | fontopen: | |
70 | @if test ! `which curl` ; then \ | |
71 | echo 'Install curl first.' >&2 ; \ | |
72 | exit 128 ; \ | |
73 | fi | |
74 | curl --silent --show-error --fail --output .fontello \ | |
75 | --form "config=@fontello_config.json" \ | |
76 | ${FONTELLO_HOST} | |
77 | x-www-browser ${FONTELLO_HOST}/`cat .fontello` | |
78 | ||
79 | ||
80 | fontsave: | |
81 | @if test ! `which unzip` ; then \ | |
82 | echo 'Install unzip first.' >&2 ; \ | |
83 | exit 128 ; \ | |
84 | fi | |
85 | @if test ! -e .fontello ; then \ | |
86 | echo 'Run `make fontopen` first.' >&2 ; \ | |
87 | exit 128 ; \ | |
88 | fi | |
89 | rm -rf .fontello.src .fontello.zip | |
90 | curl --silent --show-error --fail --output .fontello.zip \ | |
91 | ${FONTELLO_HOST}/`cat .fontello`/get | |
92 | unzip .fontello.zip -d .fontello.src | |
93 | rm -rf ${FONT_DIR} | |
94 | mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONT_DIR} | |
95 | rm -rf .fontello.src .fontello.zip | |
96 | cp ${FONT_DIR}/font/* static/fonts/ | |
97 | cp ${FONT_DIR}/css/fontello-codes.css static/fontello.css | |
98 | rm -rf ${FONT_DIR} |