Alright, next stumbling block: css reloading. My setup that’s still very similar to the getting started wiki… here’s the task I’m running:
(deftask dev
[]
(comp (serve :resource-root "public/")
(watch :verbose true)
(markdown)
(render :renderer 'nicerthantriton.core/dev-page)
(reload)
(cljs)))
I have a css file at public/css/ntt.css
in my resource folder. Since I’m serving out of public/
, my markup refers to css/ntt.css
, but when I modify the file, boot-reload tries to load public/css/ntt.css
and 404’s. I’ve figured out how to prepend a value to the asset path, but can’t seem to figure out how to tell boot-reload to leave the “public/” off the url it tries to reload. Any tips?@bhagany: pass :asset-path "public/"
to the reload task
Did cljs reloading work properly without that? I think it should run into the same issue
@martinklepsch I had tried that, but couldn’t tell what effect it had. I just tried it again, and still no effect.
I don’t have any cljs of my own in this project yet, so css is the first non-html reloading I’ve tried.
oddly, even setting :asset-path “foo/”
still results in a 404 to something like <http://localhost:3000/public/css/ntt.css?zx=24myorejoy0a>
on reload
Odd indeed, sure you're passing it to the reload task? Maybe paste relevant parts of your build.boot
here’s my entire build.boot:
(set-env!
:source-paths #{"src" "content"}
:resource-paths #{"resources"}
:dependencies '[[pandeiro/boot-http "0.7.0"]
[adzerk/boot-cljs "1.7.228-2" :scope "test"]
[adzerk/boot-reload "0.4.12" :scope "test"]
[hiccup "1.0.5"]
[perun "0.3.0" :scope "test"]])
(require '[adzerk.boot-cljs :refer [cljs]]
'[pandeiro.boot-http :refer [serve]]
'[adzerk.boot-reload :refer [reload]]
'[io.perun :refer :all])
(deftask dev
[]
(comp (serve :resource-root "public/")
(watch :verbose true)
(markdown)
(render :renderer 'nicerthantriton.core/dev-page)
(reload :asset-path "foo/")
(cljs)))
Ok so actually not odd, what asset path does is it strips something from the beginning of paths so foo/ does not have any effect
Are you getting this error when a reload is initiated or on initial load?
only on reload
I’ve manually set the href in my markup for the initial load
You may also need to pass something like asset-path to the compiler via cljs.edn
Can't look up a snippet right now but I suggest you ask in #boot more people there
I'll look something up once I'm on my computer
I did that, in order to get the load path right for reload
{:compiler-options {:asset-path “js/main.out”}}
Ok cool
I will ask in #boot in a bit - have to take my kids to school
thanks for looking at it!
Np, talk later
@bhagany so after re-reading I'd suggest :asset-path "/public"
(try with leading slash maybe that's our mistake)
It might to a ^
anchored replace so I'm optimistic that this will be the solution 🙂
Maybe we should warn if the string does not start with /
so yeah, that might be it: https://github.com/adzerk-oss/boot-reload/blob/master/src/adzerk/boot_reload/server.clj#L27
yup, that was it! Thank you.