Skip to content

Instantly share code, notes, and snippets.

@micha
Created March 30, 2015 19:29
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save micha/add9b1b2acfa95b54154 to your computer and use it in GitHub Desktop.
Save micha/add9b1b2acfa95b54154 to your computer and use it in GitHub Desktop.
(require '[boot.pod :as pod]
'[boot.util :as util]
'[clojure.java.io :as io])
(def pod-deps '[[asset-minifier "0.1.6"]])
(defn- make-minifier-pod
[]
(pod/make-pod (update-in pod/env [:dependencies] into pod-deps)))
(deftask css-min
"Minify CSS files."
[]
(let [tmp (temp-dir!)
pod (future (make-minifier-pod))]
(with-pre-wrap fileset
(empty-dir! tmp)
(doseq [[in-path in-file] (->> (input-files fileset)
(by-ext [".css"])
(map (juxt tmppath tmpfile)))]
(let [out-path (.replaceAll in-path "\\.css$" ".min.css")
out-file (io/file tmp out-path)]
(util/info "Minifying %s -> %s...\n" in-path out-path)
(pod/with-call-in @pod
(asset-minifier.core/minify-css ~(.getPath in-file) ~(.getPath out-file)))))
(-> fileset (add-resource tmp) commit!))))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment