Fork me on GitHub
#figwheel-main
<
2020-09-30
>
john22:09:12

I'd like to run some clojure code, from within the src code dir of a project, where I can get to the contents of :external-config (or some place to store a configurable var) in that clojure ns, and then shell out to cli commands that depend on the configuration vars. Do I have to handle launching the figwheel/cljs compiler manually in order to get at the env on the clojure side? Or can I get to it by requiring some things? I basically just need to be able to get some project-wide conf data from both clojure and clojurescript

lispers-anonymous23:09:40

The way I would think you have to do it is to start figwheel manually. I don't know of any pre-run hooks available to help. I'd try something like this:

(ns my-ns (:require [figwheel.main]))
(defn -main
  []
  (setup-your-stuff)
  (figwheel.main/start :dev))
And then start with clj -m my-ns

john23:09:58

Makes sense. Thanks @UDVJE9RE3!

john03:10:24

Worked out pretty good!

lispers-anonymous14:10:56

Hell yeah. I'm glad it worked because I did not try it myself lol

john22:09:40

Almost like just a custom plugin I can conditionally run before everything runs, to help set up other services. Any recommendations for how to go about that? Should I just drop the shell-outs in the user ns or is there a way to call a src file on the classpath as a preload?

john22:09:39

Being able to add a shell command directly the deps.edn or figwheel's dev.cljs.edn, that gets called in addition to the main, would suffice I think