-
Notifications
You must be signed in to change notification settings - Fork 133
/
Makefile
105 lines (80 loc) · 2.28 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
100
101
102
103
104
105
SRC = $(wildcard src/*.js)
SNIPPET = src/amplitude-snippet.js
TESTS = $(wildcard test/*.js)
BINS = node_modules/.bin
MINIFY = $(BINS)/uglifyjs
JSDOC = $(BINS)/jsdoc
BUILD_DIR = build
PROJECT = amplitude
OUT = $(PROJECT).js
SNIPPET_OUT = $(PROJECT)-snippet.min.js
SEGMENT_SNIPPET_OUT = $(PROJECT)-segment-snippet.min.js
MIN_OUT = $(PROJECT).min.js
MOCHA = $(BINS)/mocha-phantomjs
KARMA = $(BINS)/karma
ROLLUP = $(BINS)/rollup
#
# Default target.
#
default: test
#
# Clean.
#
clean:
@-rm -f amplitude.js amplitude.min.js
@-rm -rf node_modules npm-debug.log
#
# Test.
#
test: build
@$(KARMA) start karma.conf.js
@$(KARMA) start karma-web-worker.conf.js
test-sauce: build
@$(KARMA) start karma.conf.js --browsers sauce_chrome_windows
#
# Target for `node_modules` folder.
#
node_modules: package.json
@yarn
#
# Target for updating version.
version: package.json
node scripts/version
#
# Target for updating readme.
README.md: version $(SNIPPET_OUT)
node scripts/readme
#
# Target for `amplitude.js` file.
#
$(OUT): node_modules $(SRC) package.json rollup.config.js rollup.min.js rollup.esm.js rollup.umd.js rollup.umd.min.js
@NODE_ENV=production $(ROLLUP) --config rollup.config.js # is the snippet build config
@NODE_ENV=production $(ROLLUP) --config rollup.esm.js # does not concat dependencies, only has module and dependencies
@NODE_ENV=production $(ROLLUP) --config rollup.umd.js # generates npm version, also usable in require js app
@NODE_ENV=production $(ROLLUP) --config rollup.umd.min.js
@NODE_ENV=production $(ROLLUP) --config rollup.min.js
#
# Target for minified `amplitude-snippet.js` file.
#
$(SNIPPET_OUT): $(SRC) $(SNIPPET)
@$(MINIFY) $(SNIPPET) -m -b max_line_len=80,beautify=false | awk 'NF' > $(SNIPPET_OUT)
$(SEGMENT_SNIPPET_OUT): $(SRC) $(SNIPPET)
@sed -n '/createElement/,/insertBefore/!p' $(SNIPPET) | $(MINIFY) -m -b max_line_len=80,beautify=false - \
| awk 'NF' > $(SEGMENT_SNIPPET_OUT)
#
# Target for `tests-build.js` file.
#
build: $(TESTS) $(OUT) $(SNIPPET_OUT) $(SEGMENT_SNIPPET_OUT)
@$(ROLLUP) --config rollup.test.js
@$(ROLLUP) --config rollup.snippet-tests.js
@-echo "Done building"
docs:
@$(JSDOC) -d ./documentation/ src/*.js
#
# Target for release.
#
release: $(OUT) $(SNIPPET_OUT) README.md
@-mkdir -p dist
node scripts/release
.PHONY: clean
.PHONY: test