Migrate figwheel conf from project.clj to figwheel ns

Signed-off-by: Julien Eluard <julien.eluard@gmail.com>
This commit is contained in:
Itoh, Masaru 2018-02-18 21:13:53 +09:00 committed by Julien Eluard
parent cc8ef6580e
commit fad47500bb
No known key found for this signature in database
GPG Key ID: 6FD7DB5437FCBEF6
3 changed files with 28 additions and 60 deletions

21
env/dev/figwheel.clj vendored Normal file
View File

@ -0,0 +1,21 @@
(ns figwheel
(:require [clojure.string :as s]))
(defn system-options [builds-to-start]
{:nrepl-port 7888
:builds [{:id :ios
:source-paths ["react-native/src" "src" "env/dev"]
:compiler {:output-to "target/ios/app.js"
:main "env.ios.main"
:output-dir "target/ios"
:optimizations :none}
:figwheel true}
{:id :android
:source-paths ["react-native/src" "src" "env/dev"]
:compiler {:output-to "target/android/app.js"
:main "env.android.main"
:output-dir "target/android"
:optimizations :none}
:warning-handlers '[status-im.utils.build/warning-handler]
:figwheel true}]
:builds-to-start builds-to-start})

View File

@ -2,50 +2,19 @@
(:use [figwheel-sidecar.repl-api :as ra])
(:require [hawk.core :as hawk]
[re-frisk-sidecar.core :as rfs]
[clojure.string :as s]
[status-im.utils.core :as utils]))
(defn get-test-build [build]
(update build :source-paths
(fn [paths] (let [paths-set (set paths)]
(-> paths-set
(disj "env/dev")
(conj "test/cljs")
vec)))))
[status-im.utils.core :as utils]
[figwheel :as config]))
(defn start-figwheel
"Start figwheel for one or more builds"
[build-ids cljs-builds]
(ra/start-figwheel!
{:figwheel-options {:nrepl-port 7888}
:build-ids build-ids
:all-builds cljs-builds}))
[build-ids]
(ra/start-figwheel! (config/system-options build-ids)))
(defn stop-figwheel
"Stops figwheel"
[]
(ra/stop-figwheel!))
(defn test-id? [id]
(s/includes? (name id) "-test"))
(defn get-id [id]
(-> id
name
(s/replace #"-test" "")
keyword))
(defn get-builds [ids all-builds]
(keep
(fn [id]
(assoc
(let [build (get all-builds (get-id id))]
(if (test-id? id)
(get-test-build build)
build))
:id id))
ids))
(defn start
([]
(start (if *command-line-args*
@ -59,19 +28,8 @@
(spit path (str js-resourced " ;;"))
(spit path js-resourced))
ctx)}])
;; read project.clj to get build configs
(let [profiles (->> "project.clj"
slurp
read-string
(drop-while #(not= % :profiles))
(apply hash-map)
:profiles)
dev-cljs-builds (get-in profiles [:dev :cljsbuild :builds])
fig-cljs-builds (get-in profiles [:figwheel 1 :cljsbuild :builds])
cljs-builds (utils/deep-merge dev-cljs-builds fig-cljs-builds)
builds (get-builds build-ids cljs-builds)]
(start-figwheel build-ids builds)
(rfs/-main))))
(start-figwheel build-ids)
(rfs/-main)))
(def stop ra/stop-figwheel!)

View File

@ -50,18 +50,7 @@
[re-frisk-remote "0.5.3"]
[re-frisk-sidecar "0.5.4"]
[hawk "0.2.11"]]
:source-paths ["src" "env/dev"]
:cljsbuild {:builds
{:ios
{:source-paths ["react-native/src" "src" "env/dev"]
:compiler {:output-to "target/ios/app.js"
:output-dir "target/ios"}
:figwheel true}
:android
{:source-paths ["react-native/src" "src" "env/dev"]
:compiler {:output-to "target/android/app.js"
:output-dir "target/android"}
:figwheel true}}}}]
:source-paths ["src" "env/dev"]}]
:test {:dependencies [[day8.re-frame/test "0.1.5"]]
:plugins [[lein-doo "0.1.7"]]
:cljsbuild {:builds