Skip to content

Commit

Permalink
Merge pull request #76 from picture-pro/75-cache-busting
Browse files Browse the repository at this point in the history
Proper cache busting
  • Loading branch information
johnbchron authored Mar 9, 2024
2 parents 1121422 + 0f97065 commit d521cfe
Show file tree
Hide file tree
Showing 5 changed files with 13 additions and 3 deletions.
1 change: 1 addition & 0 deletions .env.example
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ LEPTOS_SITE_PKG_DIR=pkg
LEPTOS_SITE_ADDR=0.0.0.0:3000
LEPTOS_RELOAD_PORT=3001
LEPTOS_ENV=PROD
LEPTOS_HASH_FILES=true

# only for app, cannot be `/tmp` in fly
TMPDIR=/
2 changes: 1 addition & 1 deletion .github/workflows/ci.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ jobs:
- name: Use Nix Cache
uses: DeterminateSystems/magic-nix-cache-action@main
- name: Build server package
run: nix build
run: nix build -L

check:
runs-on: ubuntu-22.04
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -47,6 +47,9 @@ wasm-bindgen = "=0.2.92"
# this name is used for the wasm, js and css file names
name = "site"

# cache busting for keeping bundles up to date
hash-files = true

bin-package = "site-server"
lib-package = "site-frontend"

Expand Down
9 changes: 7 additions & 2 deletions flake.nix
Original file line number Diff line number Diff line change
Expand Up @@ -86,9 +86,13 @@
# Build *just* the cargo dependencies, so we can reuse
# all of that work (e.g. via cachix) when running in CI
site-server-deps = craneLib.buildDepsOnly (common_args // {
# if work is duplicated by the `server-site` package, update these
# commands from the logs of `cargo leptos build --release -vvv`
buildPhaseCargoCommand = ''
cargo build -p site-server --profile release --locked
cargo build -p site-frontend --target=wasm32-unknown-unknown --profile wasm-release --locked
# build the server dependencies
cargo build --package=site-server --no-default-features --release
# build the frontend dependencies
cargo build --package=site-frontend --lib --target-dir=/build/source/target/front --target=wasm32-unknown-unknown --no-default-features --profile=wasm-release
'';
});

Expand Down Expand Up @@ -117,6 +121,7 @@
installPhaseCommand = ''
mkdir -p $out/bin
cp target/release/site-server $out/bin/
cp target/release/hash.txt $out/bin/
cp -r target/site $out/bin/
'';
# Prevent cargo test and nextest from duplicating tests
Expand Down
1 change: 1 addition & 0 deletions fly.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ kill_timeout = "5s"
LEPTOS_SITE_ADDR = "0.0.0.0:3000"
LEPTOS_RELOAD_PORT = "3001"
LEPTOS_ENV = "PROD"
LEPTOS_HASH_FILES = true

# `/tmp` can't be writte to in fly, reason unknown.
TMPDIR = "/"
Expand Down

0 comments on commit d521cfe

Please sign in to comment.