aboutsummaryrefslogblamecommitdiff
path: root/cmd/web/Makefile
blob: 1d980854639fc27a19a258315940ce693671d6fb (plain) (tree)



















































                                                                                                             
SHELL=/bin/bash
ENV ?= dev
export PATH := $(PATH):./node_modules/.bin

SRC_DIR=js
BUILD_DIR=build/js
JSX_SRC= main.jsx signup.jsx signin.jsx otp.jsx poloniex.jsx
JS_SRC= cookies.js app.js api.js
JSX_OBJS=$(addprefix $(BUILD_DIR)/,$(JSX_SRC:.jsx=.js))
JS_OBJS=$(addprefix $(BUILD_DIR)/,$(JS_SRC))
STATIC_BUILD_DIR=build/static

install:
	node --version
	npm --version
	yarn --version
	yarn install

static: js $(STATIC_BUILD_DIR)/index.html $(STATIC_BUILD_DIR)/style.css

js: build/static/main.js

$(STATIC_BUILD_DIR)/index.html: static/index.html
	cp static/index.html $@

$(STATIC_BUILD_DIR)/style.css: static/style.css
	cp static/style.css $@

$(BUILD_DIR)/%.js: $(SRC_DIR)/%.jsx
	mkdir -p $(@D)
	jscs --fix $<
	babel $< -o $@
	jshint $@

$(BUILD_DIR)/%.js: $(SRC_DIR)/%.js
	jscs --fix $<
	cp $< $@
	jshint $@

build/static/main.js: $(JSX_OBJS) $(JS_OBJS) env/$(ENV).env
	browserify -t [ localenvify --envfile env/$(ENV).env ] \
						 -t [ debowerify ]  \
						 $(BUILD_DIR)/main.js -o $@

build/webapp.tar.gz: $(STATIC_BUILD_DIR)/main.js $(STATIC_BUILD_DIR)/index.html $(STATIC_BUILD_DIR)/style.css
	tar czf $@ --directory=$(dir $<) $(notdir $^)

release: build/webapp.tar.gz

clean:
	rm -rf build
	rm -rf node_modules