yogthos / lein-asset-minifier

Leiningen plugin for CSS/Js asset minifcation
Eclipse Public License 1.0
41 stars 7 forks source link

Run minify-assets from code #3

Closed tuhlmann closed 9 years ago

tuhlmann commented 9 years ago

Hi,

I'd like to run minify-assets once or in watch mode programmatically, when starting (run) from the repl (its a reagent template).

"run" starts figwheel and others, adding minify-assets there though leads to different exceptions. The simplest case I could think of was to run it once inside the main thread (no future):

(defn run-minify []
  (print "Starting minify-assets.\n")
  (lein/-main ["minify-assets"]))

This leads to the following exception:

SocketException The transport's socket appears to have lost its connection to the nREPL server
    clojure.tools.nrepl.transport/bencode/fn--7491/fn--7492 (transport.clj:95)
    clojure.tools.nrepl.transport/bencode/fn--7491 (transport.clj:95)
    clojure.tools.nrepl.transport/fn-transport/fn--7463 (transport.clj:42)
    clojure.core/binding-conveyor-fn/fn--4145 (core.clj:1910)
    java.util.concurrent.FutureTask.run (FutureTask.java:266)
    java.util.concurrent.ThreadPoolExecutor.runWorker (ThreadPoolExecutor.java:1142)
    java.util.concurrent.ThreadPoolExecutor$Worker.run (ThreadPoolExecutor.java:617)
    java.lang.Thread.run (Thread.java:745)

Is there another way to add minify-assets, or do I have to run it from a separate terminal?

Thanks.

yogthos commented 9 years ago

You would probably want to use the asset-minifier library directly instead of using the plugin.

tuhlmann commented 9 years ago

Thanks for your help! That would work. Is there a way to read the leiningen minifier settings, or do I need to repeat them?

yogthos commented 9 years ago

You could probably just read it from the project.clj

(->> (slurp "project.clj")
     read-string
     (drop-while #(not= :minify-assets %))
     second)
tuhlmann commented 9 years ago

Thanks, I got this working!