forked from magic-akari/lrc-maker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
88 lines (61 loc) · 2.51 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
tsc := node_modules/.bin/tsc
ts-node := node_modules/.bin/ts-node
webpack := node_modules/.bin/webpack
postcss := node_modules/.bin/postcss
package_json := package.json pnpm-lock.yaml
metadata := src/metadata.d.ts worker/metadata.d.ts
assets = $(shell find assets -type f)
src_ts = $(shell find src -type f \( -name '*.ts' -o -name '*.tsx' \) -not -name '*.d.ts')
src_css = $(shell find src -type f -name '*.css')
lib = $(shell find node_modules/react node_modules/react-dom -type f)
target_assets = $(patsubst assets/%,build/%,$(assets))
target_esm = $(patsubst src/%.ts,build/%.js,$(src_ts:.tsx=.ts))
target_es6 = $(patsubst build/%,build.es6/%,$(target_esm)) build/index.es6.js
target_css := build/index.css build/index.css.map
target_lib := build/lib
.PHONY: clean copy_assets copy_lib build_css build_esm watch_esm nomodule build_html dev build
target_dev = $(target_assets) $(target_lib) $(metadata) $(target_esm)
target_prod = $(target_dev) $(target_es6) $(target_css)
clean:
rm -rf ./build/* ./build.es6/*
$(target_assets): $(assets)
mkdir -p build
cp -r assets/* build
copy_assets: $(target_assets)
$(target_lib): $(lib) $(package_json)
mkdir -p build/lib
rsync -amL --exclude 'node_modules' node_modules/react node_modules/react-dom build/lib
touch build/lib
copy_lib: $(target_lib)
$(metadata): $(package_json)
$(ts-node) -P scripts/tsconfig.json scripts/generate.metadata.ts | tee src/metadata.d.ts > worker/metadata.d.ts
$(target_css): $(src_css) $(package_json)
$(postcss) src/index.css -m -d build
build_css: $(target_css)
$(target_esm): $(metadata) $(src_ts) $(package_json)
$(tsc) -b
build_esm: $(target_esm)
watch_esm:
$(tsc) -b -w
$(target_es6): $(metadata) $(src_ts) $(package_json)
$(tsc) -b tsconfig.es6.json
$(webpack) --mode=production --config=.webpack.config.cjs
nomodule: $(target_es6)
build_html:
$(ts-node) -T -P scripts/tsconfig.json scripts/index.html.tsx > build/index.html
dev: export NODE_ENV=development
dev: $(target_dev) build_html watch_esm
build: export NODE_ENV=production
build: $(target_prod) build_html
build_jsdelivr: export NODE_ENV=production
build_jsdelivr: export USE_CDN=jsdelivr
build_jsdelivr: $(target_prod) build_html
build_jsdelivr_esm: export NODE_ENV=production
build_jsdelivr_esm: export USE_CDN=jsdelivr+esm
build_jsdelivr_esm: $(target_prod) build_html
build_unpkg: export NODE_ENV=production
build_unpkg: export USE_CDN=unpkg
build_unpkg: $(target_prod) build_html
deploy: export NODE_ENV=production
deploy: export USE_CDN=jsdelivr
deploy: $(target_prod) build_html