convert_to_actix #2
15
Makefile
15
Makefile
|
@ -12,10 +12,15 @@ CARGO_RUN := cargo run
|
||||||
# Targets
|
# Targets
|
||||||
.PHONY: all frontend backend clean serve
|
.PHONY: all frontend backend clean serve
|
||||||
|
|
||||||
all: frontend backend
|
frontend_release:
|
||||||
|
make -C $(FRONTEND_DIR) release_build
|
||||||
|
cp $(FRONTEND_DIR)/index.html $(PUBLIC_DIR)/
|
||||||
|
cp $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)/
|
||||||
|
cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/
|
||||||
|
mkdir -p $(PUBLIC_DIR)/assets
|
||||||
|
|
||||||
frontend:
|
frontend_debug:
|
||||||
make -C $(FRONTEND_DIR) elm.min.js
|
make -C $(FRONTEND_DIR) debug_build
|
||||||
cp $(FRONTEND_DIR)/index.html $(PUBLIC_DIR)/
|
cp $(FRONTEND_DIR)/index.html $(PUBLIC_DIR)/
|
||||||
cp $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)/
|
cp $(FRONTEND_DIR)/elm.min.js $(PUBLIC_DIR)/
|
||||||
cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/
|
cp $(FRONTEND_DIR)/src/ports.websocket.js $(PUBLIC_DIR)/
|
||||||
|
@ -24,10 +29,10 @@ frontend:
|
||||||
backend:
|
backend:
|
||||||
$(CARGO_BUILD) --manifest-path=$(BACKEND_DIR)/Cargo.toml
|
$(CARGO_BUILD) --manifest-path=$(BACKEND_DIR)/Cargo.toml
|
||||||
|
|
||||||
serve: all
|
serve: frontend_release backend
|
||||||
$(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml
|
$(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml
|
||||||
|
|
||||||
serve_debug: all
|
serve_debug: frontend_debug backend
|
||||||
RUST_LOG=info,actix_web=debug $(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml
|
RUST_LOG=info,actix_web=debug $(CARGO_RUN) --manifest-path=$(BACKEND_DIR)/Cargo.toml
|
||||||
|
|
||||||
clean:
|
clean:
|
||||||
|
|
|
@ -3,22 +3,23 @@ Example demonstrating how one might architect a single page application
|
||||||
Elm app.
|
Elm app.
|
||||||
|
|
||||||
# Dependencies MacOS
|
# Dependencies MacOS
|
||||||
|
You will need to have rust and cargo installed on MacOS.
|
||||||
|
|
||||||
```bash
|
```bash
|
||||||
brew install node elm
|
brew install node elm
|
||||||
npm install -g uglify-js@2.4.11
|
npm install -g uglify-js@2.4.11
|
||||||
```
|
```
|
||||||
|
|
||||||
# Building
|
# Building
|
||||||
```
|
`make serve` or `make serve_debug`
|
||||||
make serve
|
|
||||||
```
|
|
||||||
|
|
||||||
Now open `http://localhost:8000` in your browser.
|
Now open `http://127.0.0.1:8080` in your browser.
|
||||||
|
|
||||||
# TODO
|
# TODO
|
||||||
|
|
||||||
- [x] Add Makefile
|
- [x] Add Makefile
|
||||||
- [ ] Add GPLV3 License
|
- [ ] Add GPLV3 License
|
||||||
|
- [ ] Add `make release` target that is nix ready...
|
||||||
- [ ] Determine if `src/Body.elm` or pages in `src/Page` should have subscription functions
|
- [ ] Determine if `src/Body.elm` or pages in `src/Page` should have subscription functions
|
||||||
- [ ] use actix backend that maps most root requests to serve `actix_file::Files`
|
- [ ] use actix backend that maps most root requests to serve `actix_file::Files`
|
||||||
- [ ] Submit to slack for feedback...
|
- [ ] Submit to slack for feedback...
|
||||||
|
|
|
@ -2,6 +2,10 @@ SRC_FILES := $(shell find src -name "*.elm")
|
||||||
|
|
||||||
all: elm.min.js
|
all: elm.min.js
|
||||||
|
|
||||||
elm.min.js: $(SRC_FILES)
|
debug_build: $(SRC_FILES)
|
||||||
rm -f elm.min.js elm.js
|
rm -f elm.min.js elm.js
|
||||||
./optimize.sh src/Main.elm
|
./build.sh --debug src/Main.elm
|
||||||
|
|
||||||
|
release_build: $(SRC_FILES)
|
||||||
|
rm -f elm.min.js elm.js
|
||||||
|
./build.sh --optimize src/Main.elm
|
||||||
|
|
21
frontend/build.sh
Executable file
21
frontend/build.sh
Executable file
|
@ -0,0 +1,21 @@
|
||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
set -e
|
||||||
|
|
||||||
|
js="elm.js"
|
||||||
|
min="elm.min.js"
|
||||||
|
|
||||||
|
if [ "$1" = "--debug" ]; then
|
||||||
|
elm make --debug --output=$js "${@:2}"
|
||||||
|
elif [ "$1" = "--optimize" ]; then
|
||||||
|
elm make --optimize --output=$js "${@:2}"
|
||||||
|
else
|
||||||
|
echo "Error: You must specify either --debug or --optimize."
|
||||||
|
exit 1
|
||||||
|
fi
|
||||||
|
|
||||||
|
uglifyjs $js --compress 'pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output $min
|
||||||
|
|
||||||
|
echo "Compiled size: $(wc -c < $js) bytes ($js)"
|
||||||
|
echo "Minified size: $(wc -c < $min) bytes ($min)"
|
||||||
|
echo "Gzipped size: $(gzip -c $min | wc -c) bytes"
|
|
@ -1,15 +0,0 @@
|
||||||
#!/bin/sh
|
|
||||||
|
|
||||||
set -e
|
|
||||||
|
|
||||||
js="elm.js"
|
|
||||||
min="elm.min.js"
|
|
||||||
|
|
||||||
elm make --debug --output=$js "$@"
|
|
||||||
# elm make --optimize --debug --output=$js "$@"
|
|
||||||
|
|
||||||
uglifyjs $js --compress 'pure_funcs=[F2,F3,F4,F5,F6,F7,F8,F9,A2,A3,A4,A5,A6,A7,A8,A9],pure_getters,keep_fargs=false,unsafe_comps,unsafe' | uglifyjs --mangle --output $min
|
|
||||||
|
|
||||||
echo "Compiled size:$(wc $js -c) bytes ($js)"
|
|
||||||
echo "Minified size:$(wc $min -c) bytes ($min)"
|
|
||||||
echo "Gzipped size: $(gzip $min -c | wc -c) bytes"
|
|
Loading…
Reference in a new issue