7

I have a macro that slurps a markdown file from resources. It provides a convenient way to provide some content. But when I edit the markdown file, Figwheel has no way to know that it needs to re-evaluate the macro.

Putting the markdown in a string inside a cljs file is undesirable because strings with newlines get indented by most Clojure editors, and this causes the markdown to be incorrect (leading spaces are meaningful in markdown).

Is there a way to detect/refresh when the markdown file changes? Or a better solution?

Here is a basic example of what I am trying to do: https://github.com/timothypratley/figwheel-watch-markdown-example

Timothy Pratley
  • 10,586
  • 3
  • 34
  • 63

1 Answers1

2

Figwheel's configs allow you to add ::watch-paths which trigger reloading when modification events come up from the file system. You can also use ::hawk-options to poll the files looking for changes, which apparently might be necessary in some environments.

Magos
  • 3,004
  • 1
  • 20
  • 20
  • 2
    Thanks for the idea... I couldn't get it working. https://github.com/timothypratley/figwheel-watch-markdown-example <-- setting the watch-paths doesn't cause recompilation or reloading to occur. Is there something I'm missing? – Timothy Pratley Sep 04 '17 at 16:24
  • @TimothyPratley did you try to set [`log-writer`](https://github.com/bhauman/lein-figwheel/blob/e47da1658a716f83888e5a5164ee88e59b2d8c1e/sidecar/src/figwheel_sidecar/components/file_system_watcher.clj#L26-L28) in `figwheel-server-options`? It could hint what might be going on with the file system watcher. – Piotrek Bzdyl Sep 04 '17 at 20:06
  • 1
    You're right, this one seems to be harder than that on account of the clj-reloading system not recognizing that the clj file with the macro has a dependency on non-Clojure files so needs recompiling when they change. Gonna try to look some more at that tomorrow. – Magos Sep 04 '17 at 22:21