Objectives/approach
- Load config conditionally, based on a release flag passed in at the command line. We use juxt/aero to read a static
config.edn
file, passing in the release flag as aero's:profile
. - Config should be exposed at runtime (in the browser / cljs) and macro-expansion time (clj). We store config in a plain map,
app.env/config
. Our build hook,app.build/load-env
, updates this usingalter-var-root!
. - Whenever config has changed, shadow-cljs must invalidate its caches so that changes are picked up immediately. We do this in
app.build/load-env
by putting the current environment in the shadow build state, under[:compiler-options :external-config ::env]
.
Why this approach?
- Reading config directly from macros breaks compiler caching - changing config will not cause changes to propagate to the build.
:clojure-defines
(ie.goog-define
) are not exposed inclj
, & therefore can't be used by macros. We want one single way to expose config that