A tiny library to handle the build meta information.
Put jp.xcoo/metabill
into the dependencies
and jp.xcoo/lein-metabill
into the plugins
of your leiningen's project.clj
.
And run lein metabill
before building for production, then it automatically generates target/metabill.edn
, which has some build metadata.
You can prevent browsers from caching old JS and CSS files using with-build-time
:
(ns hello-world.view
(:require [hiccup.page :refer [html5 include-css include-js]]
[metabill.core :refer [with-build-time]]))
(defn frame
[req]
(html5
[:head
[:title "Hello World!"]
[:meta {:charset "utf-8"}]
(include-css (with-build-time "/css/main.css"))]
[:body
[:div#app]
(include-js (with-build-time "/js/main.js"))]))
You can also use commit hash:
(ns hello-world.view
(:require [hiccup.page :refer [html5 include-css include-js]]
[metabill.core :refer [with-build-commit-hash]]))
(defn frame
[req]
(html5
[:head
[:title "Hello World!"]
[:meta {:charset "utf-8"}]
(include-css (with-build-commit-hash "/css/main.css"))]
[:body
[:div#app]
(include-js (with-build-commit-hash "/js/main.js"))]))
If you want to handle only the build metadata, you can use it as follows:
(ns hello-world.core
(:require [metabill.core :refer [get-build-time get-build-commit-hash]]))
(defn print-build-info
[]
(println "This system is built on" (get-build-commit-hash) "commit at" (get-build-time) "unix epoc."))
Copyright Xcoo, Inc.
Licensed under the Apache License, Version 2.0.
Can you improve this documentation? These fine people already did:
kbaba1001, Takashi AOKI & Toshinori NotakeEdit on GitHub
cljdoc is a website building & hosting documentation for Clojure/Script libraries
× close