I'm using ClojureScript, Boot and Boot-Cljs to build a Firefox Add-On. Firefox's Add-On SDK assumes a certain directory structure; in my case, I'll need a project-root/data
directory, which will house my contentScriptFile
.
How should I go about building a ClojureScript file, which lives in project-root/src/foo/core.cljs
and either outputting it or moving it to project-root/data
? I've tried using boot sift --move
to no avail (I admittedly don't fully understand how this task is supposed to work, which arguments are required, etc.), using a main.cljs.edn
manifest and tweaking its location, :asset-path
, :output-path
, etc. to no avail.
;; src/main.cljs.edn
{:require [foo.core]
:init-fns [foo.core/init!]
:compiler-options {:output-path "data"}}
;; build.boot
(set-env!
:source-paths #{"src" "data"}
:dependencies '[[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.170"]
[adzerk/boot-cljs "1.7.170-3"]])
(require '[adzerk.boot-cljs :refer [cljs]])
(deftask build []
(comp (cljs :optimizations :whitespace)))
I'm intrigued by Boot and want to figure this out, but I have to admit, I've wasted a lot of time on this (and it looks like I'm not alone). Seeing as I already have a simple, working Clojure script which calls the ClojureScript compiler directly - and uses :output-to
to do exactly what I need - I may revert back to that approach in order to wrap this experiment up.
The weird thing about Boot that looks to be tripping you up a bit is that tasks - such as the cljs
task - don't necessarily interact directly with the filesystem. They interact with the FileSet, a type of immutable value they are passed and expected to return.
At the beginning of the build, Boot gathers files on disk into the build's first FileSet. Then, it threads the FileSet through the task stack. Finally, Boot writes the FileSet returned by the last task to the target directory.
Boot's sift
task can be used to move files around within the FileSet, returning a new FileSet, but not to move files outside of the target directory.
Long story short, I think you can do what you want by specifying a target directory to Boot like so:
(set-env! :target-path "data" ...)