This commit is contained in:
Tienson Qin
2020-04-01 15:10:13 +08:00
parent 65dce77d65
commit 96641a26f2
59 changed files with 1917 additions and 266 deletions

31
web/dev/shadow/hooks.clj Normal file
View File

@@ -0,0 +1,31 @@
(ns shadow.hooks
(:require [clojure.java.shell :refer [sh]]
[clojure.string :as str]))
;; copied from https://gist.github.com/mhuebert/ba885b5e4f07923e21d1dc4642e2f182
(defn exec [& cmd]
(let [cmd (str/split (str/join " " (flatten cmd)) #"\s+")
_ (println (str/join " " cmd))
{:keys [exit out err]} (apply sh cmd)]
(if (zero? exit)
(when-not (str/blank? out)
(println out))
(println err))))
(defn purge-css
{:shadow.build/stage :flush}
[state {:keys [css-source
js-globs
public-dir]}]
(case (:shadow.build/mode state)
:release
(exec "purgecss --css " css-source
(for [content (if (string? js-globs) [js-globs] js-globs)]
(str "--content " content))
"-o" public-dir)
:dev
(do
(exec "mkdir -p" public-dir)
(exec "cp" css-source (str public-dir "/" (last (str/split css-source #"/"))))))
state)

7
web/dev/shadow/user.clj Normal file
View File

@@ -0,0 +1,7 @@
(ns shadow.user
(:require [shadow.cljs.devtools.api :as api]))
(defn cljs-repl
[]
(api/watch :app)
(api/repl :app))