1

I have a clj/cljs application and am using boot as the build tool.

I have a dev task which gives me an immediate feedback dev environment and it works fine!

However, I am having trouble trying to set up a build task that generates a .jar that can be deployed to production.

The issue is:

  1. The production build still tries to connect to weasel. Seen in browser console:

     websocket.js:283 WebSocket connection to 'ws://localhost:35243/' failed: Error in connection establishment: net::ERR_CONNECTION_REFUSED
    
  2. React Developer Tool (browser extension) says the application is using the dev build of reagent and points me to this url: https://reactjs.org/docs/optimizing-performance.html#use-the-production-build. (I have set the cljs compiler optimization to :advanced)

Can anyone please point me to what I am doing wrong?

My dev task is as follows:

(deftask add-cljs-dev-deps []
  (merge-env! :dependencies
              '[[cider/piggieback "0.4.1" :scope "test"]
                [nrepl "0.6.0" :scope "test"]
                ;; [com.cemerick/piggieback "0.2.2" :scope "test"]
                [weasel "0.7.0" :scope "test"]
                [org.clojure/tools.nrepl "0.2.13" :scope "test"]])
  identity)

(deftask dev
  "Launch Immediate Feedback Development Environment"
  []
  (require '[adzerk.boot-reload]
           '[pandeiro.boot-http]
           '[adzerk.boot-cljs-repl])
  (let [reload (resolve 'adzerk.boot-reload/reload)
        serve (resolve 'pandeiro.boot-http/serve)
        cljs-repl (resolve 'adzerk.boot-cljs-repl/cljs-repl)
        start-repl (resolve 'adzerk.boot-cljs-repl/start-repl)]
    (comp
     (add-cljs-dev-deps)
     (serve :handler 'myapp.core/app ;; ring handler
            :resource-root "public"  ;; root classpath
            :port 3500
            :reload true)            ;; reload ns
     (watch)
     (reload)
     (cljs-repl) ;; before cljs task
     (cljs :source-map true :optimizations :none)
     (sass)
     (target :dir #{"public"}))))

and my build task for production is as follows:

(deftask build
  "Builds an uberjar of this project that can be run with java -jar"
  []
  (comp
   (aot :all true) 
   (pom)
   (cljs :optimizations :advanced
         :compiler-options {:optimizations :advanced})
   (sass)
   (sift :move {#"(.*)js$" "public/$1js"
                #"(.*)html$" "public/$1html"
                #"css/(.*)" "public/css/$1"})
   (uber :exclude-scope #{"test"})
   (jar :file "myapp.jar" :main 'myapp.server )
   (sift :include #{#"myapp.jar"})
   (target)))

The complete build.boot can be found here.

2
  • This might help you, although the blogpost is old: blog.michielborkent.nl/2015/06/06/from-leiningen-to-boot. The idea is to use a different source folder for dev and prod to initialize the application. Jun 10, 2019 at 17:44
  • @MichielBorkent Thanks for that article! However, I am not sure how using a different source folder is going to help with this. As you can see from my dev task above, I am already separating dependencies needed only for dev into a different task, which is only being called by my dev task. However, my production build is still trying to connect to the localhost websocket for brepl. Moreover with :advanced optimizations, the development build of react is being used.
    – pvik
    Jun 10, 2019 at 18:32

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.