https://github.com/ljpengelen/lein-hash-assets
A Leiningen plugin that adds hashes to the filenames of your static assets and inserts those in your index.html
https://github.com/ljpengelen/lein-hash-assets
clojure leiningen-plugin
Last synced: 9 months ago
JSON representation
A Leiningen plugin that adds hashes to the filenames of your static assets and inserts those in your index.html
- Host: GitHub
- URL: https://github.com/ljpengelen/lein-hash-assets
- Owner: ljpengelen
- License: mit
- Created: 2021-12-03T21:04:42.000Z (over 4 years ago)
- Default Branch: main
- Last Pushed: 2022-02-01T20:35:10.000Z (over 4 years ago)
- Last Synced: 2025-03-22T09:30:26.423Z (about 1 year ago)
- Topics: clojure, leiningen-plugin
- Language: Clojure
- Homepage:
- Size: 8.79 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# lein-hash-assets
A Leiningen plugin that
1. adds md5 hashes to the filenames of your static assets and
1. uses these filenames in your `index.html`.
This allows you to permit caching of your static assets, without the risk of users ever seeing outdated versions due to caching.
Do not allow caching of `index.html` itself, however.
## Usage
First, put `[com.github.ljpengelen/lein-hash-assets "x.y.z"]` into the `:plugins` vector of your `project.clj`.
The latest version is shown in the badge below.
[](https://clojars.org/com.github.ljpengelen/lein-hash-assets)
Second, add a configuration of the following form to your `project.clj`:
```
:hash-assets {:source-root "resources/public"
:target-root "dist"
:index "index.html"
:files ["css/screen.css" "js/compiled/app.js"]}
```
Then, execute the following command:
$ lein hash-assets
For the given configuration, this will calculate the md5 hashes of `resources/public/css/screen.css` and `resources/public/js/compiled/app.js`, and save copies of these files with the corresponding hashes in their filename as `dist/css/screen-.css` and `dist/js/compiled/app-.js`.
Additionally, it will copy `resources/public/index.html` into `dist/index.html`, with all references to the original files replaced by their renamed counterparts.
## License
MIT