Vitor Barbosa 2020-03-10T09:19:33.061800Z

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?

Vitor Barbosa 2020-03-11T10:54:31.073500Z

@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'

Vitor Barbosa 2020-03-11T10:55:59.073700Z

Here figwheel-main.developer-config.edn is git ignored and can have configuration variables specific for each dev

Vitor Barbosa 2020-03-11T10:56:57.073900Z

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

Vitor Barbosa 2020-03-11T10:58:26.074100Z

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.

pyrmont 2020-03-11T15:04:57.088400Z


pyrmont 2020-03-10T09:28:53.063500Z

Does each dev need a differently named file? Or is it enough for each dev to have their own copy of the file?

pyrmont 2020-03-10T09:37:04.068800Z

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}

pyrmont 2020-03-10T09:38:09.069800Z

You'd now start it with clojure -A:fig:special.

pyrmont 2020-03-10T09:41:47.071600Z

You can specify a :connect-url in the special.cljs.edn file if that's what you need.

pyrmont 2020-03-10T09:42:00.072Z

Hope that helps.

Vitor Barbosa 2020-03-10T10:41:44.072200Z

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 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 😉

pyrmont 2020-03-10T12:10:26.073300Z

Yeah, I think your only possibly solution there is to write your own startup script that then manually starts Figwheel. Not quite ideal :(