drastically improve build scripts

This commit is contained in:
Yehowshua Immanuel 2025-01-03 13:29:56 +00:00
parent 7a59aab77d
commit db00669800
4 changed files with 13 additions and 18 deletions

View file

@ -27,11 +27,7 @@ $(PUBLIC_DIR)/index.html: $(FRONTEND_DIR)/index.html $(PUBLIC_DIR)
cp $< $@
$(FRONTEND_DIR)/elm.min.js:
ifeq ($(DEBUG),1)
make -C $(FRONTEND_DIR) DEBUG=1
else ifeq ($(RELEASE),1)
make -C $(FRONTEND_DIR) RELEASE=1
endif
make -C $(FRONTEND_DIR)
.PHONY: frontend backend
@ -47,10 +43,10 @@ serve: frontend backend
ifeq ($(DEBUG),1)
RUST_LOG=info,actix_web=debug $(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml
else ifeq ($(RELEASE),1)
$(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml
$(CARGO_RUN) --release --manifest-path=$(BACKEND_DIR)/Cargo.toml
endif
clean:
rm -rf $(PUBLIC_DIR)/*
rm -rf $(BACKEND_DIR)/target
make -C $(FRONTEND_DIR) clean

View file

@ -2,16 +2,12 @@
Example demonstrating how one might architect a single page application
Elm app.
# Dependencies MacOS
You will need to have rust and cargo installed on MacOS.
```bash
brew install node elm
npm install -g uglify-js@2.4.11
```
# Building
`make serve` or `make serve_debug`
```bash
nix-shell -p elmPackages.elm cargo uglify-js
make serve RELEASE=1 # can also do DEBUG=1 instead
```
Now open `http://127.0.0.1:8080` in your browser.

View file

@ -16,4 +16,7 @@ ifeq ($(DEBUG),1)
./build.sh --debug src/Main.elm
else ifeq ($(RELEASE),1)
./build.sh --optimize src/Main.elm
endif
endif
clean:
rm elm.js elm.min.js

View file

@ -14,8 +14,8 @@ else
exit 1
fi
uglifyjs elm.js --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters=true,keep_fargs=false,unsafe_comps=true,unsafe=true,passes=2' --output=elm.js
uglifyjs elm.js --mangle --output=elm.js
uglifyjs elm.js --compress 'pure_funcs="F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9",pure_getters=true,keep_fargs=false,unsafe_comps=true,unsafe=true,passes=2' --output elm.js
uglifyjs elm.js --mangle --output $min
echo "Compiled size: $(wc -c < $js) bytes ($js)"
echo "Minified size: $(wc -c < $min) bytes ($min)"