Skip to content

fix(build): preserve per-version assets when deduplicating (fixes unstyled non-latest doc versions)#73

Merged
maksimzinchuk merged 1 commit into
mainfrom
fix/versioned-build-preserve-per-version-assets
Jun 4, 2026
Merged

fix(build): preserve per-version assets when deduplicating (fixes unstyled non-latest doc versions)#73
maksimzinchuk merged 1 commit into
mainfrom
fix/versioned-build-preserve-per-version-assets

Conversation

@maksimzinchuk

Copy link
Copy Markdown
Collaborator

Problem

Non-latest mike doc versions lost all styling in prod (e.g. https://docs.virtocommerce.org/platform/user-guide/2.0/). Their HTML referenced a content-hashed stylesheet (main.484c7ddc.min.css) that was absent from the image, so the server returned the SPA/index fallback (200 + content-type: text/html) and the browser ignored it as CSS.

Root cause

versioned-build-cicd.pydeduplicate_assets() replaced every nested assets/ folder with a symlink to the root assets/ (the current build, e.g. hash 6543a935).

Material uses content-hashed asset filenames. A mike version built earlier with a different Material release carries a different hash. Symlinking that version's assets/ to the current-build root assets/ hid its stylesheets, so its pages pointed at a hash that no longer existed → unstyled pages.

This is also why a future mkdocs-material bump on main would silently re-break every older version: a main deploy rebuilds only the latest version, but the dedup step collapses all versions onto the new root hash.

Fix

Only deduplicate a nested assets/ folder when all of its files are also present in the root assets/. Folders with version-specific files (an older Material build's hashed assets) are kept as real files.

  • Same-build subsites still get symlinked → the ~100MB space saving is preserved.
  • Cross-version (different Material) assets are preserved → no more 404s / unstyled old versions, even across Material upgrades.

Verification

Unit-tested the function on a synthetic tree (root + a same-hash 3.0 folder + an old-hash 2.0 folder):

  • 3.0 assets/ → symlinked (deduplicated) ✅
  • 2.0 assets/ → kept as real files; old-hash CSS still present ✅
  • root assets/ intact ✅

All three live versions (1.0/2.0/3.0) currently serve content-type: text/css after the manual per-branch redeploys; this change makes that resilient to future Material upgrades without per-branch redeploys.

Refs VirtoCommerce/vc-github-actions#247

deduplicate_assets replaced every nested assets/ folder with a symlink to
the root assets/. Material uses content-hashed asset filenames, and a mike
version built with a different Material release carries a different hash.
Symlinking those folders to the current-build root assets/ hid older
versions' stylesheets, so their pages referenced a hash that no longer
existed in the image and rendered unstyled (e.g. platform/user-guide/2.0).

Only deduplicate a nested assets/ folder when all of its files are present
in the root assets/; otherwise keep it as real files. This keeps the
space savings for same-build subsites while preserving version-specific
assets across Material upgrades.

Refs VirtoCommerce/vc-github-actions#247
@CLAassistant

Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

@maksimzinchuk maksimzinchuk merged commit 4765be4 into main Jun 4, 2026
2 of 3 checks passed
@maksimzinchuk maksimzinchuk deleted the fix/versioned-build-preserve-per-version-assets branch June 4, 2026 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants