Liking cljdoc? Tell your friends :D

metabill

Clojars Project

Clojars Project

A tiny library to handle the build meta information.

Prepare

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.

Usage

Avoid browser's caching

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"))]))

network

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"))]))

Embed meta information of the build

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."))

License

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 Notake
Edit on GitHub

cljdoc is a website building & hosting documentation for Clojure/Script libraries

× close