forked from binaryage/cljs-devtools-sample
-
Notifications
You must be signed in to change notification settings - Fork 0
/
build.boot
86 lines (73 loc) · 2.56 KB
/
build.boot
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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
(set-env!
:dependencies
'[[org.clojure/clojure "1.8.0" :scope "provided"]
[org.clojure/clojurescript "1.9.229" :scope "provided"]
[org.clojure/core.async "0.2.391"]
[binaryage/devtools "0.8.2"]
[binaryage/dirac "0.6.6"]
[com.cognitect/transit-clj "0.8.288"]
[cljs-http "0.1.41"]
[environ "1.1.0"]
[boot-environ "1.1.0" :scope "test"]
[ajchemist/boot-figwheel "0.5.4-6" :scope "test"] ;; latest release
[org.clojure/tools.nrepl "0.2.12" :scope "test"]
[com.cemerick/piggieback "0.2.1" :scope "test"]
[figwheel-sidecar "0.5.7" :scope "test"]])
(require
'boot-figwheel
'[environ.boot :refer [environ]])
(require 'boot.repl)
(swap! boot.repl/*default-middleware*
conj 'cemerick.piggieback/wrap-cljs-repl)
(refer 'boot-figwheel :rename '{cljs-repl fw-cljs-repl})
(task-options!
pom {:project 'binaryage/devtools-sample
:version "0.1.0-SNAPSHOT"
:description "An example integration of cljs-devtools"})
(def all-builds
[{:id "demo"
:source-paths ["src/demo"]
:compiler '{:main devtools-sample.boot
:output-to "_compiled/demo/devtools_sample.js"
:output-dir ""
:tooling-config {:devtools/config {:features-to-install :all}}
:preloads [devtools.preload]
:optimizations :none
:source-map true}
:figwheel true}])
(def http-server-root "resources/public")
(require
'[ring.middleware file]
'[ring.util.response :as response]
'[ring.util.mime-type :as mime])
(def ring-handler
(-> (fn [{uri :uri}]
(ring.util.response/not-found
(format "<div><h1>Figwheel Server: {%s} not found</h1></div>" uri)))
(ring.middleware.file/wrap-file http-server-root {:allow-symlinks? true})
((fn [handler]
(fn [{uri :uri :as req}]
(let [resp (handler req)]
(if-let [mime-type (mime/ext-mime-type uri)]
(response/content-type resp mime-type)
resp)))))
#_(ring.middleware.content-type/wrap-content-type)
#_(ring.middleware.not-modified/wrap-not-modified)))
(def fw-options
{:server-port 7000
:server-logfile ".figwheel_server.log"
:ring-handler 'boot.user/ring-handler
:validate-config false})
(deftask demo-figwheel []
(merge-env! :source-paths #{"src/demo"})
(figwheel
:build-ids ["demo"]
:all-builds all-builds
:figwheel-options fw-options
:target-path http-server-root))
(deftask demo []
(comp
#_(target :dir #{"resources/public/_compiled/demo"} :no-clean true)
(demo-figwheel)
(repl :server true)
(wait)))