Skip to content

Instantly share code, notes, and snippets.

Created May 4, 2022 12:13
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
Star You must be signed in to star a gist
What would you like to do?
Shadow CLJS and Dart Sass
(:require [shadow.cljs.devtools.api :as shadow]
[clojure.edn :as edn]))
;; Run this with:
;; npx shadow-cljs clj-run
(set! *warn-on-reflection* true)
(defn watch
{:shadow/requires-server true}
[& _args]
;; Both watches keep running until ctrl-c.
;; You could also call bash script here, so you could manage the Sass CLI options in one place for
;; both watch and release.
(let [cmd ["npx" "sass" "--watch"
"-I" "." ;; Optional: include project root as a Sass include path
;; Redirect stdin to process, so ctrl-c is seen by sass.
;; Also redirect output to stdout.
builder (-> (ProcessBuilder. ^"[Ljava.lang.String;" (into-array String cmd))
process (.start builder)]
;; Ctrl-c would close sass, but if shadow java process is just killed,
;; we need to also kill sass.
(.addShutdownHook (Runtime/getRuntime)
;; Fn is Runnable
(fn []
(.destroy process))))
(shadow/watch :app)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment