-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
38 lines (30 loc) · 1.08 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
IMPORT_PATH = $(shell echo `pwd` | sed "s|^$(GOPATH)/src/||g")
APP_NAME = $(shell echo $(IMPORT_PATH) | sed 's:.*/::')
APP_VERSION = 0.1
TARGET = ./$(APP_NAME)-$(APP_VERSION)
GO_FILES = $(shell find . -type f -name "*.go")
BUNDLE = public/bundles
ASSETS = $(shell find assets -type f)
PID = .pid
NODE_BIN = $(shell npm bin)
build: clean $(BUNDLE) $(TARGET)
clean:
@rm -rf public/bundles
@rm -rf $(TARGET)
$(BUNDLE): $(ASSETS)
@$(NODE_BIN)/webpack --progress --colors
$(TARGET): $(GO_FILES)
@printf "Buiding go binary ......"
@go build -race -o $@
kill:
@kill `cat $(PID)` || true
dev: clean $(BUNDLE) restart
@DEV_HOT=true $(NODE_BIN)/webpack-dev-server --config webpack.config.js &
@printf "\n\nWaiting for the file change\n\n"
@fswatch --event=Updated $(GO_FILES) | xargs -n1 -I{} make restart || make kill
restart: kill $(TARGET)
@printf "\n\nrestart the app .........\n\n"
@$(TARGET) -debug & echo $$! > $(PID)
dist: clean $(TARGET)
@NODE_ENV=production $(NODE_BIN)/webpack --progress --colors
@zip -r -v $(APP_NAME)-$(APP_VERSION).zip $(TARGET) webpack-assets.json public templates