This repository has been archived by the owner on Oct 3, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathMakefile
81 lines (64 loc) · 1.98 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
#!make
.PHONY: dev install format lint build analyze preview wasm-build wasm-build-node wasm-compile wasm-gen test deploy
MAKEFLAGS += --silent
export PATH := ./node_modules/.bin:$(PATH)
project_name := "online-synth" # vercel project name
target := "bundler" # wasm target
out_dir := "target/wasm-bundler" # wasm output directory
wasm_target := "wasm32-unknown-unknown" # wasm target for cargo
# builds the wasm and starts Vite development server
dev: wasm-build
vite
# install node dependencies
install:
bun install
cargo install wasm-bindgen-cli --version 0.2.90
# code formatting using Biome, Prettier and Cargo
format:
biome format . --write
prettier . --write .
cargo fmt
# linting using Biome, ESLint, Clippy and svelte-check
lint:
biome lint . --apply-unsafe || true
eslint . --fix || true
cargo clippy || true
svelte-check --tsconfig ./tsconfig.json
# building the project
build: wasm-build
NODE_ENV=production vite build
# analyze the size of the project
analyze:
VITE_ANALYZE=true $(MAKE) build
xdg-open dist/vite_bundle_analytics.html
# previewing the built project
preview:
vite preview
# build the WebAssembly modules
wasm-build: wasm-compile wasm-gen
# generating WebAssembly bindings for Node.js
wasm-build-node:
$(MAKE) wasm-compile
$(MAKE) wasm-gen target=nodejs out_dir=target/wasm-node
# compiling Rust code to WebAssembly
wasm-compile:
rustup target add wasm32-unknown-unknown
RUSTFLAGS="-C debuginfo=0" cargo build --release --target=$(wasm_target)
# generating WebAssembly files
wasm-gen:
find target/$(wasm_target) -name '*.wasm' -not -path '*deps*' -exec wasm-bindgen {} \
--remove-name-section \
--split-linked-modules \
--remove-producers-section \
--out-dir $(out_dir) \
--target $(target) \;
# running tests
test: wasm-build-node
bun test || true
cargo test
# deploy to vercel
deploy: wasm-build
vercel build
build_url=$$(vercel --prebuilt | grep -o -E 'https:\/\/.+\.app'); \
vercel promote "$$build_url" -y
vercel remove $(project_name) --safe -y