-
Notifications
You must be signed in to change notification settings - Fork 4
Expand file tree
/
Copy pathMakefile
More file actions
55 lines (43 loc) · 1.53 KB
/
Makefile
File metadata and controls
55 lines (43 loc) · 1.53 KB
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
# µJS (muJS) - Build targets
# https://mujs.org
SRC = lib/mu.js
DIST = dist/mu.min.js
TERSER = npx terser
.PHONY: doc all clean dist publish size check hash
# Default target: documentation
doc:
@echo "$$(tput bold)Usage:$$(tput sgr0)"
@echo " make all $$(tput dim)Build minified version of the µJS library.$$(tput sgr0)"
@echo " make dist $$(tput dim)Create 'dist' directory and minify the µJS library$$(tput sgr0)."
@echo " make size $$(tput dim)Display file sizes$$(tput sgr0)."
@echo " make check $$(tput dim)Check what npm would publish$$(tput sgr0)."
@echo " make publish $$(tput dim)Publish to NPM (builds first)$$(tput sgr0)."
@echo " make clean $$(tput dim)Clean generated files.$$(tput sgr0)"
@echo " make hash $$(tput dim)Compute SRI hash.$$(tput sgr0)"
# Build minified version
all: dist
# Create dist directory and minify
dist: $(DIST)
$(DIST): $(SRC)
@mkdir -p dist
$(TERSER) $(SRC) -o $(DIST) -c -m --comments false -f 'preamble="/* µJS (muJS) - mujs.org */"'
@echo "Built $(DIST)"
@make -s size
# Display file sizes
size: $(DIST)
@echo "---"
@echo "Source: $$(wc -c < $(SRC)) bytes"
@echo "Min: $$(wc -c < $(DIST)) bytes"
@echo "Gzip: $$(gzip -c $(DIST) | wc -c) bytes"
# Dry-run: check what npm would publish
check:
npm pack --dry-run
# Publish to npm (builds first)
publish: dist
npm publish
# Clean generated files
clean:
rm -rf dist
# Compute the SHA384 hash
hash: dist
@echo "sha384-$$(cat dist/mu.min.js | openssl dgst -sha384 -binary | openssl base64 -A)"