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:
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
- 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.
dev
task above, I am already separating dependencies needed only fordev
into a different task, which is only being called by mydev
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.