fix(hooks): build css before pre-commit checks #272
Loading…
Reference in a new issue
No description provided.
Delete branch "fix/pre-commit-clean-clone"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Root cause
On a clean clone
just pre-commitfails at the clippy stage withAsset at /assets/styles.css doesn't exist.src/main.rsusesasset!("/assets/styles.css"), which the Dioxus asset macro resolves at compile time.assets/styles.cssis the Tailwind build output and is gitignored, so it is absent on a fresh checkout and clippy (and the subsequentcargo check) cannot expand the macro.Fix
Add the existing
css-buildrecipe as a prerequisite ofpre-commit(pre-commit: css-build).css-build(which itself depends onensure-npm) runsbun x @tailwindcss/cli --input input.css --output assets/styles.css, regenerating the asset before the Docker-based fmt/clippy/check/test steps run.Verification
Removed the local
assets/styles.cssto simulate a clean clone, then ranjust pre-commit: css-build regenerated the file, and all stages passed -cargo fmt --all --check,cargo clippy --all-targets -- -D warnings,cargo check --target wasm32-unknown-unknown, andcargo test --lib(146 passed; 0 failed). Final line:[pre-commit] all checks passed(exit 0).Part of DEV-370.
Add css-build as a prerequisite of the pre-commit recipe so the Tailwind output exists before clippy and cargo check run. src/main.rs uses asset!("/assets/styles.css"), which requires the built CSS file at compile time, but assets/styles.css is gitignored (a build output), so on a clean clone it is absent and clippy fails with `Asset at /assets/styles.css doesn't exist`. css-build (already present, depends on ensure-npm) regenerates it via bun + the Tailwind CLI before the Docker-based checks. #DEV-370