Add `--fingerprint` option to `marten collectassets` for cache-busting
treagod opened this issue · 0 comments
treagod commented
Description
This proposal aims to enhance the marten collectassets command with an optional --fingerprint flag to streamline cache-busting and deployment processes in simple applications.
Functionality
When the --fingerprint flag is set, the marten collectassets should add a unique fingerprint to the filename of each collected asset.
Also a manifest.json should be generated, which maps the original asset filenames to their fingerprinted counterparts.
Example manifest.json:
{
"assets/css/app.css": "assets/css/app.3d7ea1.css"
}
The generated manifest.json has to be set manually in your Marten configuration (e.g., in config/settings/production.cr
):
Marten.configure :production do |config|
# Rest of config
config.assets.manifest = "path/to/manifest.json"
end
Motivation
- Improved Cache-Busting: Fingerprinting assets ensures browsers always load the latest versions after deployment and prevents stale cache issues.
- Simplified Deployment: This feature can reduce reliance on external asset pipelines for straightforward applications.
- Optional Behavior: The
--fingerprint
flag maintains flexibility for developers who prefer their own asset handling.