Hello! I was wondering what is the best way to have developer-specific configs for figwheel-main builds? For example, I need each developer to be able to specify :connect-url
. Hopefully I would like to do it in a file that is git-ignored, so each dev can keep it's own config there without having to explicitly skip it all the time. At the same time, I want to keep a default for the :connect-url
because it is okay for most of the devs. Is there an easy way to achieve this?
@mike858 I found a nice solution:
lein 'trampoline' 'run' '-m' 'figwheel.main' '-co' 'dev.cljs.edn' '-fwo' 'figwheel-main.edn:figwheel-main.developer-config.edn' '-c' '-r'
Here figwheel-main.developer-config.edn
is git ignored and can have configuration variables specific for each dev
I put this in a makefile so we can just run make run
and it will read from figwheel-main.edn
and figwheel-main.developer-config.edn
and merge the configs from left to right
Here is the relevant part from figwheel --help
-fwo, --fw-opts edn Options to configure figwheel.main, can be an EDN
string or system-dependent path-separated list of
EDN files / classpath resources. Options will be
merged left to right.
Nice!
Does each dev need a differently named file? Or is it enough for each dev to have their own copy of the file?
If the latter, you can have an alias in your deps.edn
file that passes a build name as an option:
aliases {:fig {:extra-deps
{com.bhauman/rebel-readline-cljs {:mvn/version "0.1.4"}
com.bhauman/figwheel-main {:mvn/version "0.2.3"}}
:extra-paths ["target" "test"]}
:build {:main-opts ["-m" "figwheel.main" "-b" "dev" "-r"]}
:min {:main-opts ["-m" "figwheel.main" "-O" "advanced" "-bo" "dev"]}
:special {:main-opts ["-m" "figwheel.main" "-b" "special" "-r"]}
:test {:main-opts ["-m" "figwheel.main" "-co" "test.cljs.edn" "-m" "pondent.test-runner"]}}}
In that example, you can now have a file called special.cljs.edn
that has the connection URL.
^{:watch-dirs ["test" "src"]
:css-dirs ["resources/public/css"]
:open-url "<http://[%5Bserver-hostname%5D]:%5B%5Bserver-port%5D%5D/index.html|http://[[server-hostname]]:[[server-port]]/index.html>"
:ring-server-options {:host "[your-url]" :port [your-port]}}
{:main [your-main-ns].core}
You'd now start it with clojure -A:fig:special
.
You can specify a :connect-url
in the special.cljs.edn
file if that's what you need.
Hope that helps.
Thanks @mike858. Yes it does help. I was wondering that maybe there was a way to "merge" config files "automagically", so I could keep something like app.dev.cljs.edn
and have figwheel merge it to an app.cljs.edn
. But if there is not, then I'll probably use something similar to your suggestion 😉
Yeah, I think your only possibly solution there is to write your own startup script that then manually starts Figwheel. Not quite ideal :(