Fixup the just watch command

And add more docs about it.
This commit is contained in:
Tyler Hallada 2023-06-29 00:00:26 -04:00
parent 3f744c0c50
commit ec90069c30
2 changed files with 16 additions and 8 deletions

View File

@ -72,12 +72,15 @@ It also separately watches the files in `frontend/` which will trigger a
transpilation with `bun` and then rebuild the server binary so that it includes transpilation with `bun` and then rebuild the server binary so that it includes
the new JS bundle names. the new JS bundle names.
Alternatively, you can just run `cargo run`. Alternatively, you can just run `cargo run` after building the frontend
JavaScript with `just build-dev-frontend`.
### Building for Production ### Building for Production
You can also build the binary in release mode for running in production with the You can also build the binary in release mode for running in production with the
`just build` command (or `cargo build --release`). `just build` command. This will first build the minified frontend JavaScript
(`just build-frontend`) and then build the rust binary with `cargo build
--release`.
## Using the CLI ## Using the CLI

View File

@ -9,26 +9,31 @@ install-frontend:
clean-frontend: clean-frontend:
rm -rf ./static/js/* rm -rf ./static/js/*
build-frontend: install-frontend clean-frontend build-frontend: clean-frontend
bun build frontend/index.ts \
--outdir ./static/js \
--entry-naming [name]-[hash].[ext] \
--minify
build-dev-frontend: clean-frontend
bun build frontend/index.ts \ bun build frontend/index.ts \
--outdir ./static/js \ --outdir ./static/js \
--entry-naming [name]-[hash].[ext] --entry-naming [name]-[hash].[ext]
touch .frontend-built # triggers watch-backend since static/* is ignored
watch-frontend: install-frontend watch-frontend: install-frontend
cargo watch -w frontend \ cargo watch -w frontend \
-s 'rm -rf ./static/js/*' \ -s 'just build-dev-frontend'
-s 'bun build frontend/index.ts \
--outdir ./static/js \
--entry-naming [name]-[hash].[ext]' \
-s 'touch .frontend-built'
watch-backend: watch-backend:
mold -run cargo watch \ mold -run cargo watch \
--ignore 'logs/*' \ --ignore 'logs/*' \
--ignore 'static/*' \ --ignore 'static/*' \
--ignore 'frontend/*' \ --ignore 'frontend/*' \
--no-vcs-ignores \
-x run -x run
# runs watch-frontend and watch-backend simultaneously
watch: watch:
./watch.sh ./watch.sh