]> git.immae.eu Git - perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git/blame - cmd/web/Makefile
Update static assets.
[perso/Immae/Projets/Cryptomonnaies/Cryptoportfolio/Front.git] / cmd / web / Makefile
CommitLineData
7a9e5112 1SHELL=/bin/bash
2ENV ?= dev
3export PATH := $(PATH):./node_modules/.bin
4
335b0c9b 5# Javascript objects
6JS_SRC_DIR=js
7JS_BUILD_DIR=build/js
8JSX_SRC=header_footer.jsx main.jsx signup.jsx signin.jsx otp.jsx poloniex.jsx password_reset.jsx change_password.jsx account.jsx balance.jsx admin.jsx panel.jsx icon.jsx
9JS_SRC=cookies.js app.js api.js
10JSX_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JSX_SRC:.jsx=.js))
11JS_OBJS=$(addprefix $(JS_BUILD_DIR)/,$(JS_SRC))
12
13# Static resources
7a9e5112 14STATIC_BUILD_DIR=build/static
335b0c9b 15STATIC_FILES=index.html style.css
7a9e5112 16
335b0c9b 17# Fontello icon provider - regular icons
18STATIC_FILES+=fontello.css
19STATIC_FILES+=$(addprefix fonts/, fontello.eot fontello.svg fontello.ttf fontello.woff fontello.woff2)
20FONTELLO_TMP_DIR = ./static/fontello
21FONTELLO_HOST ?= http://fontello.com
22
23# Biticonics cryptocurrency icon provider.
24STATIC_FILES+=$(addprefix fonts/, bitonics.min.css)
25CRYPTO_ICONS_FONTS=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/ttf/, $(notdir $(wildcard static/fonts/glyphs/ttf/*.ttf)))
26CRYPTO_ICONS_FONTS+=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/woff/, $(notdir $(wildcard static/fonts/glyphs/woff/*.woff)))
27CRYPTO_ICONS_FONTS+=$(addprefix $(STATIC_BUILD_DIR)/fonts/glyphs/woff2/, $(notdir $(wildcard static/fonts/glyphs/woff2/*.woff2)))
28
29define fetch-bitonics-icons =
30 DIR="static/fonts/glyphs"
31
32 curl 'https://bitonics.net/vendor/bitonics/bitonics.min.css' > static/fonts/bitonics.min.css
33
34 glyphs=($(curl 'https://bitonics.net/vendor/bitonics/bitonics.css' | grep -Po 'glyphs/ttf/[a-z0-9]{8}' | cut -c 12-))
35
36 for glyph in "${glyphs[@]}"
37 do
38 if [ ! -f "$DIR/ttf/$glyph.ttf" ]; then
39 curl "https://bitonics.net/vendor/bitonics/glyphs/ttf/$glyph.ttf" > "$DIR/ttf/$glyph.ttf"
40 curl "https://bitonics.net/vendor/bitonics/glyphs/woff/$glyph.woff" > "$DIR/woff/$glyph.woff"
41 curl "https://bitonics.net/vendor/bitonics/glyphs/woff2/$glyph.woff2" > "$DIR/woff2/$glyph.woff2"
42 fi
43 done
44endef
45
46# Rules
7a9e5112 47install:
48 node --version
49 npm --version
50 yarn --version
51 yarn install
52
335b0c9b 53$(JS_BUILD_DIR):
2f91f20a 54 mkdir -p $@
78e3e81d 55
56$(STATIC_BUILD_DIR)/fonts:
57 mkdir -p $@
7a9e5112 58
335b0c9b 59$(STATIC_BUILD_DIR)/fonts/glyphs:
60 mkdir -p $@/ttf
61 mkdir -p $@/woff
62 mkdir -p $@/woff2
63
64static: js $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) $(CRYPTO_ICONS_FONTS)
65
66js: build/static/main.js
67
68$(STATIC_BUILD_DIR)/%: static/% $(STATIC_BUILD_DIR)/fonts
69 cp $< $@
70
71$(JS_BUILD_DIR)/%.js: $(JS_SRC_DIR)/%.jsx
989fb5c7 72 eslint --fix $<
73 cp $< $@
7a9e5112 74
335b0c9b 75$(JS_BUILD_DIR)/%.js: $(JS_SRC_DIR)/%.js
989fb5c7 76 eslint $<
7a9e5112 77 cp $< $@
7a9e5112 78
335b0c9b 79$(STATIC_BUILD_DIR)/fonts/glyphs/%: static/fonts/glyphs/% $(STATIC_BUILD_DIR)/fonts/glyphs
6b3f0ad0 80 cp $< $@
81
335b0c9b 82build/static/main.js: $(JS_BUILD_DIR) $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env
989fb5c7 83 browserify -t [ babelify --presets [ env react ] --plugins [ transform-class-properties ] ] \
84 -t [ localenvify --envfile env/$(ENV).env ] \
85 -t [ debowerify ] \
335b0c9b 86 $(JS_BUILD_DIR)/main.js -o $@
7a9e5112 87
335b0c9b 88build/webapp.tar.gz: $(addprefix $(STATIC_BUILD_DIR)/, $(STATIC_FILES)) build/static/main.js $(CRYPTO_ICONS_FONTS)
6b3f0ad0 89 tar czf $@ --directory=$(dir $<) $(subst $(STATIC_BUILD_DIR)/,,$^)
7a9e5112 90
335b0c9b 91release: build/webapp.tar.gz
7a9e5112 92
93clean:
94 rm -rf build
2f91f20a 95 rm -rf node_modules
bf5deb87 96
335b0c9b 97fontello-open:
bf5deb87 98 @if test ! `which curl` ; then \
99 echo 'Install curl first.' >&2 ; \
100 exit 128 ; \
101 fi
102 curl --silent --show-error --fail --output .fontello \
71e53148 103 --form "config=@static/fontello_config.json" \
bf5deb87 104 ${FONTELLO_HOST}
105 x-www-browser ${FONTELLO_HOST}/`cat .fontello`
106
335b0c9b 107fontello-save:
bf5deb87 108 @if test ! `which unzip` ; then \
109 echo 'Install unzip first.' >&2 ; \
110 exit 128 ; \
111 fi
112 @if test ! -e .fontello ; then \
113 echo 'Run `make fontopen` first.' >&2 ; \
114 exit 128 ; \
115 fi
116 rm -rf .fontello.src .fontello.zip
117 curl --silent --show-error --fail --output .fontello.zip \
118 ${FONTELLO_HOST}/`cat .fontello`/get
119 unzip .fontello.zip -d .fontello.src
335b0c9b 120 rm -rf ${FONTELLO_TMP_DIR}
121 mv `find ./.fontello.src -maxdepth 1 -name 'fontello-*'` ${FONTELLO_TMP_DIR}
bf5deb87 122 rm -rf .fontello.src .fontello.zip
335b0c9b 123 cp ${FONTELLO_TMP_DIR}/font/* static/fonts/
124 cp ${FONTELLO_TMP_DIR}/css/fontello-codes.css static/fontello.css
71e53148 125 cp ${FONTELLO_TMP_DIR}/config.json static/fontello_config.json
335b0c9b 126 rm -rf ${FONTELLO_TMP_DIR}
127
128
129crypto-icons: ; $(value fetch-bitonics-icons)
130
71e53148 131.ONESHELL: