-
Notifications
You must be signed in to change notification settings - Fork 1
/
build.clj
59 lines (45 loc) · 1.67 KB
/
build.clj
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
(require '[cljs.build.api :as api]
'[clojure.string :as string]
'[figwheel-sidecar.repl-api :as figwheel]
'[figwheel-sidecar.components.nrepl-server :as figwheel.nrepl])
(def source-dir "src")
(def compiler-config
{:main 'otarta.core
:output-to "target/app.js"
:source-map "target/app.js.map"
:output-dir "target/out"
:target :nodejs
:optimizations :simple
:npm-deps {:websocket "1.0.26"}
:install-deps true})
(def dev-config
(merge compiler-config
{:optimizations :none
:source-map true}))
(def nrepl-options
{:nrepl-port 7890
:nrepl-middleware ["cider.nrepl/cider-middleware"
"cider.piggieback/wrap-cljs-repl"]})
(def ensure-nrepl-port! #(spit ".nrepl-port" (:nrepl-port nrepl-options)))
(def figwheel-options
{:figwheel-options nrepl-options
:all-builds [{:id "dev"
:figwheel true
:source-paths [source-dir]
:compiler dev-config}]})
;;; Tasks --------------------------------------------------------------------------------
(defmulti task first)
(defmethod task :default [_]
(task ["repl"]))
(defmethod task "compile" [_]
(api/build source-dir compiler-config))
(defmethod task "compile-watch" [_]
(api/watch source-dir compiler-config))
(defmethod task "repl" [_]
(ensure-nrepl-port!)
(figwheel.nrepl/start-nrepl-server nrepl-options nil)
(println "Started nREPL server on port:" (:nrepl-port nrepl-options)))
(defmethod task "figwheel" [_]
(ensure-nrepl-port!)
(figwheel/start-figwheel! figwheel-options))
(task *command-line-args*)