This page is not created by, affiliated with, or supported by Slack Technologies, Inc.
2023-12-14
Channels
- # adventofcode (29)
- # aws (3)
- # babashka (25)
- # beginners (13)
- # calva (4)
- # cherry (7)
- # cider (26)
- # clj-kondo (9)
- # clojure (88)
- # clojure-europe (21)
- # clojure-losangeles (3)
- # clojure-nl (1)
- # clojure-norway (6)
- # clojure-uk (11)
- # clojuredesign-podcast (2)
- # clojurescript (4)
- # cursive (10)
- # datalevin (1)
- # emacs (50)
- # gratitude (1)
- # honeysql (12)
- # hyperfiddle (19)
- # jobs-discuss (28)
- # kaocha (3)
- # lsp (53)
- # malli (4)
- # meander (3)
- # off-topic (48)
- # re-frame (11)
- # releases (2)
- # ring-swagger (2)
- # shadow-cljs (50)
- # squint (26)
- # tools-build (3)
- # tools-deps (8)
- # xtdb (4)
- # yamlscript (1)
I have a feeling this isn't possible but if this should I can file an issue instead, figured itd be easier to talk out first.
So I have a #CNMR41NKB SSR app which works beautifully now, the only issue I am missing is CSS hot reloading. Because the app is server rendered, I can't use the shadow http server (but if that solves the problem I can work around it) so I just need some way to trigger to shadow the files have changed and to do a hot reload. On the ring side, my css file has the timestamp hack appended so there's no caching issues.
I have tried :watch-dir
pointed at resources/public/css
(every combination I can think of) and nothing triggers, but I suspect this is because I'm not using the dev-http server but there is still hot loading of the js just fine so I'm sure there's a way to get this working 😄
{:source-paths ["src" "resources"]
:dependencies
[[com.pitch/uix.core "1.0.1"]
[com.pitch/uix.dom "1.0.1"]
[binaryage/devtools "1.0.7"]
[com.adamrenklint/preo "0.1.0"]
[cider/cider-nrepl "0.44.0"]]
:builds
{:app {:output-dir "resources/public/js"
:asset-path "/js"
:target :browser
:modules {:main {:init-fn client.client/init}}
:devtools {:watch-dir "resources/"
:preloads [client.preload]}}}}
is the shadow-cljs, the project isn't confidential or anything it's just not got a public repo, if it's easier I can push it and link it here 😄I guess you could pull in some bits from shadow.resource
ns, IIRC the slurp-resource
fn will pull in a resources and also force compiler to rebuild and hot-load when the resource is updated
Hmm, that might work but I'd favour a more general solution because there may be other resources down the line I'm just focusing on the CSS for now. That's a good start though, thanks!
:watch-dir "resources/public"
assuming the actual css files sit in resources/public/css
and are served via http /css/whatever.css
note that changing :watch-dir
requires restarting the build. so it you tried stuff without restarting it wouldn't work
1) Why might I not be getting any output from my shadow-cljs :build-hooks
when I am using shadow.cljs.util/log
calls within them?
2) Also, is there a good way to add a new hook and try it out dynamically without needing to keep restarted everything?
log output goes to where the shadow-cljs process was started. could be that is hidden in cider or something
regardless ... I'd develop them in the usual REPL workflow, reloading the CLJ namespace from the REPL and stuff
don't know what that means, prep likely shouldn't be done in a hook if you ask me though
Well some of it is for convenience when starting a repl to have things get done in that single JVM step. Like building sass commands and cache busting it. But that isn’t critical and could be earlier shell steps - just more clunky to build that into something like cider-jack-in.
More pressing is that we are currently still going to be using webpack to bundle until I can see if what shadow does works for us and migrate.
I need to run the bundles after shadow compiles cljs but before the rest of the repl can be used since my webserver needs the bundle. Also it all has to be cache busted etc.
In figwheel you use the bundle target and it gives you a time to slip in the bundle command automatically after the compilation. In shadow I think I just have to use a hook.
Keep in mind I’m working with multiple people teams. And we have an easy jack in sort of flow with figwheel. So having a bunch of weird new steps for everyone isn’t ideal.
here is how I go about doing things, it is basically described in this readme https://github.com/thheller/shadow-css?tab=readme-ov-file#development-builds
I can hack a bunch at the jack-in command script too. But trying to do the least. We also have a few calva users.
this function you write and have full control over. there is no need to shadow-cljs to call it or know what it does
you can start shadow-cljs watches from the clj API, or anything shadow-cljs for that matter
there is absolutely no need to have shadow-cljs do things it isn't meant to do via build hooks 😛
You want to kick off the bundler as soon as the cljs compiled js is done. Ie. the flush phase