Magnus
Magnus

Reputation: 4714

Dealing with resources (copying) when building a ClojurScript project using leiningen

I have just begun playing with ClojureScript and I'd like to collect all CSS files into a single folder (out/css). I found leiningen-less and with the following config I get the compiled CSS files into the correct location:

:less {:source-paths ["src/less"] :target-path "out/css"}

I can't find any documentation on how I can handle the ordinary CSS files (e.g. the file for resetting defaults, css/reset.css). Basically I want the equivalent of cp css/*css out/css.

I did find lein-resource but it does a bit more than I require (pass things through stencil) and more importantly it through an UnsupportedOperationException on my with what I thought would a be a valid configuration:

:resource {:resource-paths ["css" {:target-path "out/css"}]}

Please englighten me!

Upvotes: 1

Views: 511

Answers (2)

tangrammer
tangrammer

Reputation: 3061

I think better and easy solution would be that you write a function that uses clojure.java.io library functions and integrate them with lein-less "compiler" fork, so this is my internal function proposal:

(defn your-fn[] 
  (remove-folder "./out") ;; => you have to do how to make that fn following io lib doc
  (copy-folder "./css ./out") ;; ;; => you have to do how to make that fn following io lib doc
  (run-compiler  :javascript
                 {:project-root "your-project-root/"
                  :source-paths ["less"]
                  :target-path "out"})))

PS: note that you need to call this fn from your clojurescript compilation process, BTW I didn't know if there is a way for that :)

Upvotes: 0

Joaquin
Joaquin

Reputation: 2744

For your particular use case just rename reset.css to reset.less. less should be able to read CSS without problems.

For more advanced frontend tooling maybe consider adding something like make/grunt/etc. More complexity but more power & flexibility.

Upvotes: 1

Related Questions