The root index.html always points to the active version. Each deployment’s assets are isolated in their own folder — this enables instant switching between versions.
Vite Config
Dynamic base path ensures assets are referenced correctly from each subfolder:
This variable sets the deployment subfolder (commit SHA or tag). If unset, it defaults to root /. This way each folder’s index.html references its own assets via the correct relative path.
Rollback Strategy
Step 1 — Copy Previous Version to Root
Identify the commit SHA or tag you want to roll back to, then copy its index.html to the bucket root:
Invalidation is only needed for index.html since asset files have unique hashes in their filenames and are cached indefinitely.
Why This Works
flowchart LR
A[CloudFront] -->|serves| B["/index.html (root)"]
B -->|references| C["/abc123/assets/*"]
D["Rollback: copy old index.html to root"] -.->|now references| E["/def456/assets/*"]
The root index.html is the only file that needs to be replaced. It contains references to assets in the corresponding subfolder (thanks to VITE_RELEASE_PATH in the Vite config). Old assets remain in place — switching happens instantly.