This repository has been archived by the owner on Dec 20, 2023. It is now read-only.
forked from pirxpilot/liftie
-
Notifications
You must be signed in to change notification settings - Fork 1
/
Makefile
121 lines (88 loc) · 2.53 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
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
PROJECT=liftie
NODE_BIN=./node_modules/.bin
BUILD_DIR=public/scripts
CSS_DIR=public/stylesheets
SRC = $(wildcard lib/client/*/*.js)
TESTS = $(filter-out test/replay/%, $(wildcard test/*.js test/*/*.js))
LINT_SRC = app.js bin/generate lib test
PLUGINS = lifts twitter weather webcams snow
ESBUILD_OPTS += \
--bundle \
--log-level=warning \
--color=false \
--tree-shaking=true \
--target=es2018
ESBUILD_MIN_OPTS += \
--define:DEBUG=false \
--drop:console \
--drop:debugger \
--minify
define RUN_ESBUILD
$(NODE_BIN)/esbuild $< \
$(ESBUILD_OPTS) \
--sourcemap=linked \
--outfile=$@
endef
define RUN_ESBUILD_MIN
$(NODE_BIN)/esbuild $< \
$(ESBUILD_OPTS) \
$(ESBUILD_MIN_OPTS) \
--sourcemap=external \
--sources-content=false \
--outfile=$@
endef
ifndef TAP_REPORTER
ifneq (, $(shell which tap-difflet))
TAP_REPORTER = tap-difflet --pessimistic
else
TAP_REPORTER = cat
endif
endif
all: lint test build
# common rules
%.br: %
brotli --best --force $<
%.gz: %
gzip --best --force --keep $<
%.styl.css: %.styl
$(NODE_BIN)/stylus $<
%.css: %.styl.css
$(NODE_BIN)/postcss \
--use postcss-cachify \
--postcss-cachify.baseUrl /stylesheets \
--postcss-cachify.basePath public \
--output $@ $@
%.min.css: %.css
$(NODE_BIN)/cleancss -O1 --output $@ $<
node_modules: package.json $(wildcard yarn.lock)
yarn --cwd $(@D) --no-progress --frozen-lockfile --silent
touch $@
lint: | node_modules
$(NODE_BIN)/jshint $(LINT_SRC)
test: | node_modules
$(NODE_BIN)/tape $(TESTS) | $(TAP_REPORTER)
$(BUILD_DIR):
mkdir -p $@
$(BUILD_DIR)/$(PROJECT).js: lib/client/boot/index.js $(SRC) node_modules | $(BUILD_DIR)
NODE_PATH=lib/client:node_modules $(RUN_ESBUILD)
$(BUILD_DIR)/$(PROJECT).min.js: lib/client/boot/index.js $(SRC) node_modules | $(BUILD_DIR)
NODE_PATH=lib/client:node_modules $(RUN_ESBUILD_MIN)
$(BUILD_DIR)/$(PROJECT)-embed.js: lib/embed/index.js | $(BUILD_DIR)
$(RUN_ESBUILD)
$(BUILD_DIR)/$(PROJECT)-embed.min.js: lib/embed/index.js | $(BUILD_DIR)
$(RUN_ESBUILD_MIN)
# stylus for CSS
$(CSS_DIR)/style.css: $(wildcard $(CSS_DIR)/*.styl)
build: $(BUILD_DIR)/$(PROJECT).js $(CSS_DIR)/style.css $(BUILD_DIR)/$(PROJECT)-embed.js
# minized and compressed version for deployment
DIST = $(BUILD_DIR)/$(PROJECT).min.js $(CSS_DIR)/style.min.css $(BUILD_DIR)/$(PROJECT)-embed.min.js
.PRECIOUS: $(DIST)
dist: $(DIST:%=%.gz)
# dist: $(DIST:%=%.br)
# cleaning
clean:
rm -rf $(BUILD_DIR) $(CSS_DIR)/style.css* $(CSS_DIR)/style.min.css*
distclean: clean
distclean:
rm -rf node_modules
.PHONY: all test build dist clean distclean