Shared Assets
Shared assets allow you to separate where files are served from (release directory) from where they are physically stored (shared/), so that frequently reused assets don't need to be re-uploaded every time.
Enable Shared Assets
json
{
"enable_shared": true,
"hashed_asset_patterns": [
"**/*.js",
"**/*.css",
"**/*.png",
"**/*.jpg",
"**/*.svg",
"**/*.woff2"
]
}enable_shared: turns shared asset management on for the environment.hashed_asset_patterns: glob patterns for files that should be treated as shared assets (typically files with content hashes in their names, such asapp-abc123.js).
How It Works
File Matching
- After build, Shipfe scans
local_dist_pathand matches files byhashed_asset_patterns. - All matched files are recorded as
hashed_assetsinshipfe.snapshot.jsonusing their relative paths, e.g.assets/app-abc123.js,assets/images/logo-xyz999.png.
- After build, Shipfe scans
Normal Release Extraction
The full
distdirectory is always uploaded and extracted into:remote_deploy_path/ releases/<timestamp>/... # exactly the same structure as local distThe web server serves from
remote_deploy_path/current, so the URL structure matchesdist.
Shared Storage Strategy
For each path
pinhashed_assets:- Source:
releases/<timestamp>/{p} - Target:
shared/{p}
- Source:
Shipfe moves the file and creates a hard link back:
bashmv -f releases/<timestamp>/{p} shared/{p} ln -f shared/{p} releases/<timestamp>/{p}This means:
- Release directory structure is unchanged (paths in
current/are identical todist). - Shared directory mirrors the same relative paths under
shared/. - If a file with the same path already exists in
shared/, it is overwritten (mv -f).
- Release directory structure is unchanged (paths in
Link Creation
- Requests still hit
current/...as usual. - The filesystem ensures those files physically live under
shared/...via hard links.
- Requests still hit
Cleanup
- Current implementation does not automatically delete old files under
shared/. - If you want to drop history and reclaim disk space, you can manually clean
shared/when no deployments are running.
- Current implementation does not automatically delete old files under
Directory Structure Example
remote_deploy_path/
├── shared/
│ └── assets/
│ ├── app-abc123.js
│ └── images/
│ └── logo-xyz999.png
├── releases/
│ └── 20260304_120100/
│ ├── index.html
│ ├── assets/
│ │ ├── app-abc123.js -> ../../../shared/assets/app-abc123.js
│ │ └── images/
│ │ └── logo-xyz999.png -> ../../../../shared/assets/images/logo-xyz999.png
│ └── ...
└── current -> releases/20260304_120100Example Patterns
Minimal: only JS/CSS bundles
json"hashed_asset_patterns": [ "assets/**/*.js", "assets/**/*.css" ]Full assets directory (including images, fonts, etc.)
json"hashed_asset_patterns": [ "assets/**" ]
In all cases, file paths under shared/ follow the same relative layout as under dist.
Notes
- Requires filesystem support for hard links on the server.
hashed_asset_patternsonly controls which files participate in the shared mechanism; other files remain as normal files in each release.- Shared assets are an optimization; if you prefer simpler behavior, set
enable_sharedtofalsefor the environment.