clojurescript - How to get cljsbuild to run BEFORE uberjar compiles a clojure app? -
i'm making isomorphic app in clojure / clojurescript / reagennt. due fact have dependency on clojurescript output js file server-side rendering, i'd file compiled before jar does. how do that?
here's output of "lein uberjar" notice jar compiled first. clj file "nash.clj" needs run compiled server-side.js build:
johns-macbook-pro:bfa-clojure johnkealy$ lein uberjar minifying assets... minifying: resources/public/css/site.min.css assets: site.css original size: 88983 compressed size: 73886 gzipped size: 13676 compiling bfa-clojure.api.auth compiling bfa-clojure.api.misc compiling bfa-clojure.api.photos compiling bfa-clojure.global compiling bfa-clojure.handler compiling bfa-clojure.nash compiling bfa-clojure.pages compiling bfa-clojure.server 2015-08-17 14:34:32.964:info::main: logging initialized @21242ms compiling clojurescript. compiling "resources/public/javascripts/server-side.js" ("src/cljs" "src/server-cljs" "src/clj/bfa_clojure/queries" "src/cljs" "src/server-cljs" "src/clj/bfa_clojure/queries")... compiled "resources/public/javascripts/server-side.js" in 7.441 seconds.
and project.clj...the whole cljsbuild thing mystery me.
(defproject bfa-clojure "0.1.0-snapshot" :description "fixme: write description" :url "http://example.com/fixme" :license {:name "eclipse public license" :url "http://www.eclipse.org/legal/epl-v10.html"} :source-paths ["src/clj" "src/cljs"] :dependencies [[org.clojure/clojure "1.7.0"] [ring-server "0.4.0"] [cljsjs/react "0.13.3-1"] [reagent "0.5.0"] [reagent-forms "0.5.4"] [reagent-utils "0.1.5"] [ring "1.4.0"] [cider/cider-nrepl "0.7.0"] [org.clojure/tools.nrepl "0.2.3"] [ring/ring-defaults "0.1.5"] [prone "0.8.2"] [cheshire "5.3.1"] [fogus/ring-edn "0.3.0"] [org.clojure/data.json "0.2.6"] [com.cemerick/url "0.1.1"] [org.clojure/core.async "0.1.267.0-0d7780-alpha"] [clj-http "2.0.0"] [compojure "1.4.0"] [cljs-ajax "0.3.13"] [hiccup "1.0.5"] [environ "1.0.0"] [org.clojure/clojurescript "0.0-3308" :scope "provided"] [mori "0.2.4"] [secretary "1.2.3"]] :less {:source-paths ["src/less"] :target-path "resources/public/css"} :plugins [[lein-less "1.7.5"] [lein-environ "1.0.0"] [lein-asset-minifier "0.2.2"]] :ring {:handler bfa-clojure.handler/app :uberwar-name "bfa-clojure.war"} :min-lein-version "2.5.0" :uberjar-name "bfa-clojure.jar" :main bfa-clojure.server :clean-targets ^{:protect false} [:target-path [:cljsbuild :builds :app :compiler :output-dir] [:cljsbuild :builds :app :compiler :output-to]] :minify-assets {:assets {"resources/public/css/site.min.css" "resources/public/css/site.css"}} :cljsbuild {:builds {:app {:source-paths ["src/cljs" "src/client-cljs" "src/clj/bfa_clojure/queries"] :compiler {:output-to "resources/public/js/app.js" :output-dir "resources/public/js/out" :asset-path "/js/out" :optimizations :none :pretty-print true}}}} :profiles {:dev {:repl-options {:init-ns bfa-clojure.repl :nrepl-middleware []} :dependencies [[ring-mock "0.1.5"] [ring/ring-devel "1.4.0"] [lein-figwheel "0.3.7"] [org.clojure/tools.nrepl "0.2.10"] [pjstadig/humane-test-output "0.7.0"]] :source-paths ["env/dev/clj"] :plugins [[lein-figwheel "0.3.7"] [lein-cljsbuild "1.0.6"]] :injections [(require 'pjstadig.humane-test-output) (pjstadig.humane-test-output/activate!)] :figwheel {:http-server-root "public" :server-port 3449 :nrepl-port 7002 :css-dirs ["resources/public/css"] :ring-handler bfa-clojure.handler/app} :env {:dev true} :cljsbuild {:builds {:app {:source-paths ["env/dev/cljs"] :compiler {:main "bfa-clojure.dev" :source-map true}} :server {:id "server-side" :source-paths ["src/cljs" "src/server-cljs" "src/clj/bfa_clojure/queries"] :compiler {:output-to "resources/public/javascripts/server-side.js" :output-dir "resources/public/javascripts/out-server-side" :preamble ["underscore-min.js"] :pretty-print false :warnings true :optimizations :whitespace}}}}} :uberjar {:hooks [leiningen.cljsbuild minify-assets.plugin/hooks] :env {:production true} :aot :all :omit-source true :cljsbuild {:jar true :main "bfa-clojure.core" :builds { :server {:id "server-side" :source-paths ["src/cljs" "src/server-cljs" "src/clj/bfa_clojure/queries"] :compiler {:output-to "resources/public/javascripts/server-side.js" :output-dir "resources/public/javascripts/out-server-side" :preamble ["underscore-min.js"] :pretty-print false :warnings true :optimizations :whitespace}} :app {:source-paths ["env/prod/cljs"] :externs ["underscore-min.js"] :compiler {:optimizations :advanced :externs ["underscore-min.js"] :pretty-print false}}}}}})
you have add cljsbuild hooks in project.clj:
:hooks [leiningen.cljsbuild]
about lein uberjar
output, say:
notice jar compiled first
that's not what's happening. see output following tasks, in order: - lein minify (or whatever named task minifies css) - lein compile - lein cljsbuild once
we can't output if jar task has run before or after tasks, that's how works: default, uberjar runs clean
-> javac
-> compile
-> jar
the hook makes cljsbuild run after compile
task. that's why see "compiling bfa-clojure.api.auth..." before "compile clojurescript"
Comments
Post a Comment