diff --git a/bb.edn b/bb.edn index 45bdbb8..2692236 100644 --- a/bb.edn +++ b/bb.edn @@ -1,5 +1,6 @@ {:paths ["bb"] - :deps {hiccup/hiccup {:mvn/version "1.0.5"}} + :deps {hiccup/hiccup {:mvn/version "1.0.5"} + clojure.java-time/clojure.java-time {:mvn/version "1.1.0"}} :min-bb-version "0.4.0" :tasks {clean {:doc "clean temporary assets" diff --git a/build.clj b/build.clj new file mode 100755 index 0000000..dc92d2d --- /dev/null +++ b/build.clj @@ -0,0 +1,41 @@ +#!/usr/bin/env bb +(require '[babashka.fs :as fs] + '[babashka.process :refer [process]] + '[java-time.api :as jt]) + +(def dist "_build") +(def tmp-dir (-> (fs/create-temp-dir) + (fs/delete-on-exit))) + +(def tmp-css (fs/file tmp-dir "tmp.css")) +(def brut-css "brut.min.css") + +(fs/create-dirs dist) + +(def sub-css + ["colors" + "extended-colors" + "general" + "buttons" + "grid" + "components" + "headings" + "icons" + "forms" + "navbar" + "tables" + "messages"]) + +(spit tmp-css (str "/* Copyright %s Yann Esposito; MIT licensed */" + (jt/year (jt/local-date)))) +(doseq [item sub-css] + (println "building: %s" item) + (let [css (fs/file tmp-dir (str item ".css")) + min-css (fs/file tmp-dir (str item ".min.css"))] + (process ["lessc" (format "src/%s.less" item)] {:out css}) + (process ["minify" min-css] {:out min-css}) + (when-not (= "extended-colors" item) + (spit tmp-css (slurp min-css) :append true)))) + +(fs/move tmp-css brut-css :replace-existing :atomic-move) +(println "build: " brut-css)