This repository has been archived by the owner on Jun 20, 2021. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 76
/
Copy pathMakefile
99 lines (76 loc) · 2.18 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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
.PHONY: all
.PHONY: flow-stop check check-coverage test lint
.PHONY: assets styles source build package
.PHONY: server clean
DIST_DIR =./dist
BUILD_DIR =./build
BIN_DIR =./node_modules/.bin
SCRIPT_DIR=./scripts
DIR=.
BRANCH ?=$(shell git rev-parse --abbrev-ref HEAD)
VERSION =$(shell git describe --tags HEAD)
REVISION=$(shell git rev-parse HEAD)
STAMP =$(REVISION).$(shell date +%s)
all: setup check lint test package
setup: deps symlink
fmt:
$(BIN_DIR)/prettier --write ./src/**/*.js
symlink:
$(SCRIPT_DIR)/symlink.sh
deps:
npm install
flow-stop:
$(BIN_DIR)/flow stop
check:
$(BIN_DIR)/flow
check-coverage:
$(SCRIPT_DIR)/check-coverage.sh
test:
$(BIN_DIR)/jest
lint:
$(BIN_DIR)/eslint ./src
build: symlink dirs assets styles source
dirs:
mkdir -p $(BUILD_DIR) $(DIST_DIR)
assets:
cp -r ./assets $(BUILD_DIR)
styles:
$(BIN_DIR)/node-sass \
--source-map true \
--source-map-embed \
--source-map-contents \
--output-style compressed \
./styles/index.sass > $(BUILD_DIR)/index.css
source:
$(BIN_DIR)/browserify \
src/app.js \
--debug \
-t babelify \
-t [ envify \
--VERSION "$(VERSION)" \
--REVISION "$(REVISION)" \
--STAMP "$(STAMP)" \
--NODE_ENV "$(NODE_ENV)" \
--MIXPANEL_TOKEN "$(MIXPANEL_TOKEN)" \
] \
| $(BIN_DIR)/exorcist $(BUILD_DIR)/bundle.js.map \
> $(BUILD_DIR)/_bundle.js
mv $(BUILD_DIR)/_bundle.js $(BUILD_DIR)/bundle.js
package: clean build
cp -r index.html opensearch.xml $(BUILD_DIR) $(DIST_DIR)
sed -i 's build/bundle build/$(STAMP) g' $(DIST_DIR)/index.html
sed -i 's build/index build/$(STAMP) g' $(DIST_DIR)/index.html
mv $(DIST_DIR)/$(BUILD_DIR)/index.css $(DIST_DIR)/$(BUILD_DIR)/$(STAMP).css
$(BIN_DIR)/uglifyjs $(DIST_DIR)/$(BUILD_DIR)/bundle.js > $(DIST_DIR)/$(BUILD_DIR)/$(STAMP).js
rm $(DIST_DIR)/$(BUILD_DIR)/bundle.js
gzip -c -9 $(DIST_DIR)/$(BUILD_DIR)/$(STAMP).css > $(DIST_DIR)/$(BUILD_DIR)/$(STAMP).css.gz
gzip -c -9 $(DIST_DIR)/$(BUILD_DIR)/$(STAMP).js > $(DIST_DIR)/$(BUILD_DIR)/$(STAMP).js.gz
release: NODE_ENV=production
release: package
$(SCRIPT_DIR)/release.sh
server:
$(BIN_DIR)/static-server -n $(DIR)/index.html -f $(DIR)
clean:
rm -rf $(BUILD_DIR) $(DIST_DIR)
cleanall: clean
rm -rf node_modules