Created
March 30, 2015 19:29
-
-
Save micha/add9b1b2acfa95b54154 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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