-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathbuild.boot
More file actions
103 lines (93 loc) · 4.04 KB
/
build.boot
File metadata and controls
103 lines (93 loc) · 4.04 KB
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
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
(set-env!
:source-paths #{"src"}
:resource-paths #{"resources"}
:dependencies '[[adzerk/boot-cljs "2.0.0" :scope "test"]
[adzerk/boot-reload "0.5.1" :scope "test"]
[binaryage/devtools "0.9.3" :scope "test"]
[binaryage/dirac "1.2.4" :scope "test"]
[crisptrutski/boot-cljs-test "0.3.0" :scope "test"]
[devcards "0.2.3" :scope "test"]
[org.clojure/clojure "1.8.0" :scope "test"]
[org.clojure/clojurescript "1.9.521" :scope "test"]
[pandeiro/boot-http "0.7.6" :scope "test"]
[powerlaces/boot-cljs-devtools "0.2.0" :scope "test"]
[tolitius/boot-check "0.1.4" :scope "test"]])
(require
'[adzerk.boot-cljs :refer [cljs]]
'[adzerk.boot-reload :refer [reload]]
'[crisptrutski.boot-cljs-test :refer [test-cljs]]
'[powerlaces.boot-cljs-devtools :refer [cljs-devtools]]
'[pandeiro.boot-http :refer [serve]]
'[tolitius.boot-check :as check])
;; Required to define custom test task.
(ns-unmap 'boot.user 'test)
(def closure-opts
"Common Closure Compiler options for each build."
{:output-wrapper :true})
(def target-path
"Default directory for build output."
"target")
;; Define default task options used across the board.
(task-options! reload {:on-jsload 'projectname.common.reload/handle}
serve {:dir target-path}
target {:dir #{target-path}}
test-cljs {:exit? true :js-env :phantom})
(deftask build
"Produce a production build with optimizations."
[]
(let [{:keys [closure-defines]} closure-opts
new-defines (merge closure-defines
{'projectname.common.config/production true})
prod-closure-opts (merge closure-opts {:closure-defines new-defines})]
(comp
(sift :include #{#"^devcards"} :invert true)
(cljs :optimizations :advanced
:compiler-options prod-closure-opts)
(sift :include #{#"\.out" #"\.cljs\.edn$" #"^\." #"/\."} :invert true)
(target))))
(deftask dev
"Produce a development build."
[d devcards bool "Include devcards in build."
s server bool "Start a local server with dev tools and live updates."
p port PORT int "The port number to start the server in."]
(let [{:keys [closure-defines]} closure-opts
new-defines (merge closure-defines
{'projectname.common.config/devcards devcards
'projectname.common.config/hot-reload server})
dev-closure-opts (merge closure-opts {:closure-defines new-defines})
tasks [(if server (serve :port port))
(if server (watch))
(if server (speak))
(if-not devcards (sift :include #{#"^devcards"} :invert true))
(if server (reload))
(if server (cljs-devtools))
(cljs :source-map true
:optimizations :none
:compiler-options dev-closure-opts)
(sift :include #{#"\.cljs\.edn$" #"^\." #"/\."} :invert true)
(target)]]
(apply comp (remove nil? tasks))))
(deftask devcards
"Produce a build containing devcards only with optimizations."
[]
(let [{:keys [closure-defines]} closure-opts
new-defines (merge closure-defines
{'projectname.common.config/devcards true})
cards-closure-opts (merge closure-opts {:closure-defines new-defines})]
(comp
(sift :include #{#"^(?!devcards).*\.cljs\.edn$"} :invert true)
(cljs :optimizations :advanced
:compiler-options cards-closure-opts)
(sift :include #{#"^assets/" #"^devcards(?!\.(cljs\.edn|out))"})
(target))))
(deftask lint
"Check and analyze source code."
[]
(comp
(sift :include #{#"\.clj[cs]?$"})
(check/with-kibit)
(check/with-bikeshed)))
(deftask test
"Run all tests."
[]
(test-cljs))