A small Clojure/Babashka library for hashing static assets.
manifest-edn
is a utility library designed to solve the problem of cache busting for static assets in Clojure applications. It provides functionality to:
This approach ensures that when asset content changes, the filename also changes, forcing browsers to download the new version instead of using a cached copy.
Add the dependency to your project:
;; deps.edn
{:deps {io.github.abogoyavlensky/manifest-edn {:mvn/version "LATEST"}}}
;; or Leiningen/Boot
[io.github.abogoyavlensky/manifest-edn "LATEST"]
Use fetch-assets!
to download remote assets and save them locally:
(require '[manifest-edn.core :as manifest])
(manifest/fetch-assets! [{:url "https://cdn.example.com/jquery.min.js"
:filepath "js/jquery.min.js"}
{:url "https://cdn.example.com/styles.css"
:filepath "css/styles.css"}])
This will download the specified files and save them to the resources/public
directory.
As a second argument you can specify a path to a directory where you want to save the assets:
(manifest/fetch-assets! ...
{:resources-dir "custom-resources"
:public-dir "custom-public"})
Use hash-assets!
to process all static assets in your public directory:
;; With default options
(manifest/hash-assets!)
;; Or with custom options
(manifest/hash-assets!
{:resource-dir "custom-resources"
:public-dir "static"
:resource-dir-target "dist"})
This will:
app.js
-> app.a1b2c3d4.js
)Use the asset function to get the correct path to a hashed asset:
(require '[manifest-edn.core :as manifest])
;; In your HTML templates
(def js-path (manifest/asset "js/app.js"))
;; => "/assets/js/app.a1b2c3d4.js"
;; With custom asset prefix
(def css-path (manifest/asset "static" "css/styles.css"))
;; => "/static/css/styles.e5f6g7h8.css"
The function will return the hashed path if available, or fall back to the original path if not found in the manifest. This is useful, for example, in development.
"resources"
"public"
"resources-hashed"
- this directory will be created automatically and supposed to be ignored by git"manifest.edn"
- this file will be created automatically at the root of target directory"assets"
Install Java, Clojure and Babashka manually or via mise:
mise install
Note: Check versions in .mise.toml
file.
All management tasks:
bb tasks
The following tasks are available:
deps Install all deps
fmt-check Check code formatting
fmt Fix code formatting
lint-init Import linting configs
lint Linting project's code
test Run tests
outdated-check Check outdated Clojure deps versions
outdated Upgrade outdated Clojure deps versions
check Run all code checks and tests
install-snapshot Install snapshot version locally
install Install version locally
deploy-snapshot Deploy snapshot version to Clojars
deploy-release Deploy release version to Clojars
release Create and push git tag for release
bb install
Note: Publishing to Clojars requires CLOJARS_USERNAME
and CLOJARS_PASSWORD
environment variables.
Deploy snapshot version:
bb deploy-snapshot
Deploy release version:
bb deploy-release
Set up following secrets for Actions:
CLOJARS_USERNAME
CLOJARS_PASSWORD
Then you will be able to push to master branch to deploy snapshot version automatically.
Once you decide to publish release you just need to bump version at deps.edn:
:aliases -> :build -> :exec-args -> :version -> "0.1.1
and create a git tag with this version. There is a shortcut command for this:
bb release
This command will create a git tag with the latest version from deps.edn and push it to git repository. Github Actions will automatically deploy a release version to Clojars.
MIT License Copyright (c) 2025 Andrey Bogoyavlenskiy
Can you improve this documentation?Edit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close