martenframework / marten

The pragmatic web framework.
https://martenframework.com
MIT License
415 stars 22 forks source link

Add `--fingerprint` option to `marten collectassets` for cache-busting #205

Closed treagod closed 6 months ago

treagod commented 6 months ago

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