Closed bamarco closed 8 years ago
Thanks so much for working on this!
I'd rather keep as much figwheel (and other dev) logic away from app as possible. But of course, we need to inject figwheel in the system somewhere. I'd say do your best to come up with a nice separation of things, but at the end of the day just do what works.
I'm not sure what the problem is with start.cljs
and goog.require
; Can you clarify for me please? I think at the very least, we'd like to make it so a prod build leaves out the figwheel system component.
@metasoarous
Yeah no problem, I'm having fun.
So if you load figwheel this way in dev/user.clj
:
(ns user
(:require
;; other requires...
[dat.sys.figwheel-server :as fserver]))
(def system nil)
(defn init
([config-overrides]
(alter-var-root #'system (fn [_] (assoc (system/create-system config-overrides)
:http-server (component/using (fserver/new-figwheel-server) [:datomic :config :ring-routes])))))
([] (init {})))
Then you have a system
that only loads figwheel
during development, but if you try using fw/watch-and-reload
you can't hardcode in the figwheel server port like start.cljs
currently does because it comes from the configuration during runtime. That's okay because figwheel allows for a project.clj
config parameter with a callback function :figwheel {:on-jsload "dat.sys.client.app/on-figwheel-reload"}
. When I tried using dat.sys.client.start/on-figwheel-reload
it couldn't find it, but now that I've explained it to you I think I could get start.cljs
to work if i put the dat/sys/client/start.cljs
folders in the dev folder.
@metasoarous Okay so I figured out the problem. Figwheel doesn't do profile lein merging. I have the project.clj configured in a way that has the figwheel stuff in development only. So the current need for separate index files is no longer necessary. So the question is: Do you foresee other reasons for index.html file divergence or do you want them merged back into one?
Wonderful! I'd love not to have two index.html
files. That's something I've been wanting to accomplish anyway. I would've avoided that myself had I written from scratch, but I inherited that setup from Rente. So yeah, merge away.
Hey @bamarco How do things look on this to merge? Is it running for you and are you satisfied with things?
@metasoarous Yeah everything seems to be in order. I think it's good to go.
@metasoarous in
app.cljs
When using a figwheel server component,start.cljs
is not compiled and available for goog.require to call when the ring-handler is called because figwheel hasn't run yet. Instead, I made changes to theproject.clj
file so that there is anon-figwheel-reload
function. Where do you want me to put the function. Is it okay inapp.cljs
or do you want it in its own file?It also seems like main won't need to be called in the reload function, but I'm not sure so I have it commented out. My current implementation looks like:
I'm also not sure if you want me to go ahead and combine the
index.html
back to one file?