Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
(set-env! :target-path "target/dev"
:source-paths #{"sass" "src" "resources" "dev-cljs"}
:asset-paths #{"assets"}
:dependencies '[[adzerk/boot-cljs "1.7.48-5" :scope "test"]
[adzerk/boot-cljs-repl "0.3.0" :scope "test"]
[adzerk/boot-reload "0.4.0" :scope "test"]
[deraen/boot-less "0.5.0"]
[mathias/boot-sassc "0.1.5" :scope "test"]
[org.clojure/clojure "1.8.0"]
[org.clojure/tools.nrepl "0.2.12"]
[org.clojure/tools.logging "0.3.1"]
[org.slf4j/jcl-over-slf4j "1.7.13"]
[org.slf4j/jul-to-slf4j "1.7.13"]
[org.slf4j/log4j-over-slf4j "1.7.13"]
[ch.qos.logback/logback-classic "1.1.3" :exclusions [org.slf4j/slf4j-api]]
[com.cemerick/piggieback "0.2.1" :scope "test"] ;; Needed for start-repl in cljs repl
[weasel "0.7.0" :scope "test"]]);; Websocket Server
(intern
(the-ns 'boot.core)
'resolve-dependencies? (atom true))
(alter-var-root
#'boot.core/add-dependencies!
(fn [orig]
(fn [old new env]
(if @boot.core/resolve-dependencies? (orig old new env) new))))
(defmacro with-env
[env-map expr]
`(let [orig-env# (boot.core/get-env)
new-env# ~env-map]
(reset! boot.core/resolve-dependencies? false)
(apply boot.core/set-env! (mapcat identity new-env#))
(let [result# ~expr]
(apply boot.core/set-env! (mapcat identity orig-env#))
(reset! boot.core/resolve-dependencies? true)
result#)))
(require '[boot.pod :as pod])
(require '[adzerk.boot-cljs :refer [cljs]]
'[adzerk.boot-cljs-repl :refer [cljs-repl start-repl]]
'[adzerk.boot-reload :refer [reload]]
'[boot.pod :as pod]
'[clojure.java.shell :as sh]
'[mathias.boot-sassc :refer [sass]]
'[deraen.boot-less :refer [less]])
(def server-deps '[[aleph "0.4.1-beta3"]
[bidi "1.24.0"]
[hiccup "1.0.5"]
[org.omcljs/om "1.0.0-alpha28"]
[yada "1.1.0-20160126.014942-13"]
[com.stuartsierra/component "0.3.1"]
[reloaded.repl "0.2.1"]
[prismatic/schema "1.0.4"]
[org.clojure/core.async "0.2.374"]
[org.clojure/tools.reader "0.10.0"]
[org.clojure/tools.logging "0.3.1"]
[org.slf4j/jcl-over-slf4j "1.7.13"]
[org.slf4j/jul-to-slf4j "1.7.13"]
[org.slf4j/log4j-over-slf4j "1.7.13"]
[ch.qos.logback/logback-classic "1.1.3" :exclusions [org.slf4j/slf4j-api]]
[org.clojure/tools.namespace "0.2.10"]])
(deftask server
"Develop the server backend"
[]
(with-env
{:dependencies server-deps
:source-paths #{"src" "resources" "dev"}}
(repl :init-ns 'user :port 5700)))
(deftask frontend
"Simple alias to run frontend application"
[]
(let [reload (resolve 'adzerk.boot-reload/reload)
cljs-repl (resolve 'adzerk.boot-cljs-repl/cljs-repl)
cljs (resolve 'adzerk.boot-cljs/cljs)
cljs-build-deps (resolve 'adzerk.boot-cljs/deps)
less (resolve 'deraen.boot-less/less)
sass (resolve 'mathias.boot-sassc/sass)
;; Direct Clojurescript Code dependencies
cljs-deps '[[org.omcljs/om "1.0.0-alpha28"]
[org.clojure/core.async "0.2.374"]
[org.clojure/clojurescript "1.7.170"]]
remove-unneeded-deps
(fn [deps]
;; # Reasons to keep each:
;; - adzerk/boot-cljs The impl stuff needs this as a dep
;; - adzerk/boot-reload Reloading requires that the cljs namespace of this is pulled in
;; - weasel Websocket client
(filter (comp #{'weasel 'adzerk/boot-cljs 'adzerk/boot-reload} first) deps))
cljs-env
{:dependencies (-> (boot.core/get-env :dependencies)
remove-unneeded-deps
(concat @@(resolve 'adzerk.boot-cljs/deps))
(concat cljs-deps)
vec)
:source-paths #{"src" "dev-cljs" "resources"}}]
(println cljs-env)
(comp
(watch)
(speak)
#_(sass :sass-file "app.scss"
:output-dir "."
:line-numbers true
:source-maps true)
(with-env
{:source-paths #{"sass"}}
(less :source-map true))
(reload :on-jsload 'edge.main/init)
(cljs-repl :nrepl-opts {:port 5710})
(with-env
cljs-env
(cljs :ids #{"edge"} :optimizations :none))
(target :dir #{"target/dev"}))))
#_(deftask build-frontend
"Compiles frontend application"
[]
(set-env! :target-path "target/prod")
(comp
(less :source-map false)
(cljs :ids #{"edge"} :optimizations :advanced)
(target :dir #{"target/prod"})))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment