-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathJustfile
67 lines (53 loc) · 1.57 KB
/
Justfile
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
name := 'plasma_web'
dist_file := name + ".tar.xz"
target_dir := 'target/wasm32-unknown-unknown/release/'
features := env_var_or_default('FEATURES', "")
node_env := env_var_or_default('NODE_ENV', "production")
# Build and optimize wasm files
all: wasm opt
# Install npm deps
install:
npm install
# Compile and serve
serve: wasm
npm run serve
# Create distribution files
webpack:
NODE_ENV={{node_env}} npx webpack
# Build wasm and bindgen files
wasm: build bindgen
# Build wasm files
build:
cargo build --lib --release --package plasma-web --features={{features}}
# Create wasm interface in JS and TS
bindgen:
wasm-bindgen --typescript --remove-name-section --remove-producers-section --out-dir . ../{{target_dir}}{{name}}.wasm
# Make the binary *even smaller* if you installed `wasm-opt`
opt:
wasm-opt -O4 {{name}}_bg.wasm -o {{name}}_bg.wasm
# Clean cargo and bindgen artefacts
clean:
cargo clean
rm -f {{name}}.js
rm -f {{name}}.d.ts
rm -f {{name}}_bg.js
rm -f {{name}}_bg.d.ts
rm -f {{name}}_bg.wasm
rm -f {{name}}_bg.wasm.d.ts
# Clean and remove all compiled files from dist and doc
distclean: clean
rm -f "{{dist_file}}"
rm -rf dist doc
# Gzip all files in static for distribution
gzip:
for file in dist/*.{css,js,map,html,wasm}; do \
gzip -9 -c "$file" >"$file".gz && touch -r "$file" "$file".gz; \
done
# Prepare distribution tar
pack:
tar -cvaf "{{dist_file}}" dist
# Build and create distribution files
dist: all webpack gzip pack
# Generate TypeScript documentation
doc:
npx typedoc --tsconfig tsconfig.json