perun

Discuss perun static site generator
bhagany 2016-10-31T02:52:04.000091Z

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?

martinklepsch 2016-10-31T08:57:41.000092Z

@bhagany: pass :asset-path "public/" to the reload task

martinklepsch 2016-10-31T08:58:37.000093Z

Did cljs reloading work properly without that? I think it should run into the same issue

bhagany 2016-10-31T12:08:30.000094Z

@martinklepsch I had tried that, but couldn’t tell what effect it had. I just tried it again, and still no effect.

bhagany 2016-10-31T12:08:53.000095Z

I don’t have any cljs of my own in this project yet, so css is the first non-html reloading I’ve tried.

bhagany 2016-10-31T12:47:01.000097Z

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

martinklepsch 2016-10-31T12:48:23.000098Z

Odd indeed, sure you're passing it to the reload task? Maybe paste relevant parts of your build.boot

bhagany 2016-10-31T12:48:45.000099Z

here’s my entire build.boot:

bhagany 2016-10-31T12:48:47.000100Z

(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)))

martinklepsch 2016-10-31T12:50:02.000102Z

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

martinklepsch 2016-10-31T12:50:21.000103Z

Are you getting this error when a reload is initiated or on initial load?

bhagany 2016-10-31T12:50:43.000104Z

only on reload

bhagany 2016-10-31T12:50:51.000105Z

I’ve manually set the href in my markup for the initial load

martinklepsch 2016-10-31T12:51:04.000106Z

You may also need to pass something like asset-path to the compiler via cljs.edn

martinklepsch 2016-10-31T12:51:40.000107Z

Can't look up a snippet right now but I suggest you ask in #boot more people there

martinklepsch 2016-10-31T12:51:52.000108Z

I'll look something up once I'm on my computer

bhagany 2016-10-31T12:51:56.000109Z

I did that, in order to get the load path right for reload

bhagany 2016-10-31T12:51:59.000110Z

{:compiler-options {:asset-path “js/main.out”}}

martinklepsch 2016-10-31T12:52:11.000111Z

Ok cool

bhagany 2016-10-31T12:52:28.000112Z

I will ask in #boot in a bit - have to take my kids to school

bhagany 2016-10-31T12:52:35.000113Z

thanks for looking at it!

martinklepsch 2016-10-31T12:52:46.000114Z

Np, talk later

martinklepsch 2016-10-31T14:06:00.000115Z

@bhagany so after re-reading I'd suggest :asset-path "/public" (try with leading slash maybe that's our mistake)

martinklepsch 2016-10-31T14:16:07.000117Z

It might to a ^ anchored replace so I'm optimistic that this will be the solution 🙂

martinklepsch 2016-10-31T14:16:16.000118Z

Maybe we should warn if the string does not start with /

martinklepsch 2016-10-31T14:18:12.000119Z

so yeah, that might be it: https://github.com/adzerk-oss/boot-reload/blob/master/src/adzerk/boot_reload/server.clj#L27

bhagany 2016-10-31T14:39:30.000121Z

yup, that was it! Thank you.

bhagany 2016-10-31T14:39:44.000122Z

@martinklepsch ^