-
Notifications
You must be signed in to change notification settings - Fork 0
/
Makefile
74 lines (55 loc) · 1.2 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
PROJECT=plan-microdata
GLOBALVAR=furkotPlanMicrodata
BUILD_DIR=build
SCRIPT_NAME=$(BUILD_DIR)/furkot-$(PROJECT)
BIN=./node_modules/.bin
SRC = $(wildcard lib/*.js)
ESBUILD_OPTS += \
--bundle \
--log-level=warning \
--color=false \
--tree-shaking=true \
--global-name=$(GLOBALVAR)
--target=es2020
ESBUILD_MIN_OPTS += \
--define:DEBUG=false \
--drop:console \
--drop:debugger \
--minify
define RUN_ESBUILD
$(BIN)/esbuild $< \
$(ESBUILD_OPTS) \
--sourcemap=linked \
--outfile=$@
endef
define RUN_ESBUILD_MIN
$(BIN)/esbuild $< \
$(ESBUILD_OPTS) \
$(ESBUILD_MIN_OPTS) \
--sourcemap=external \
--sources-content=false \
--outfile=$@
endef
%.gz: %
gzip --best --stdout $< > $@
all: check compile
check: lint
lint: node_modules
$(BIN)/jshint lib
compile: $(SCRIPT_NAME).js
build:
mkdir -p $@
$(SCRIPT_NAME).js: lib/index.js $(SRC) node_modules | $(BUILD_DIR)
$(RUN_ESBUILD)
$(SCRIPT_NAME).min.js: lib/index.js $(SRC) node_modules | $(BUILD_DIR)
$(RUN_ESBUILD_MIN)
node_modules: package.json
yarn
touch $@
clean:
rm -rf $(BUILD_DIR)
distclean: clean
rm -rf node_modules
.PRECIOUS: $(SCRIPT_NAME).min.js
dist: $(SCRIPT_NAME).min.js.gz
.PHONY: all lint test compile dist clean distclean