Can Leiningen be configured in such way that it bundles all compiled JS to a single file? Currently it outputs over a hundred files, which would be very slow in production.
I'm using Chestnut boilerplate, by the way. The documentation says:
Q: I just want to compile ClojureScript to fully optimized JavaScript, so I can use it in a static HTML site.
A: Invoke cljsbuild with the uberjar profile active, like this:
lein with-profile -dev,+uberjar cljsbuild once, then look forresources/public/js/app.js.
I've tried it, but the resulting app.js is still just loads the dependencies from other files, it doesn't contain the whole app.
As pointed out in the comments: make sure you use one of the following :optimizations:
:whitespace:simple:advancedYou can find more information in the ClojureScript wiki: https://github.com/clojure/clojurescript/wiki/Compiler-Options#optimizations
It seems like lein with-profile -dev,+uberjar cljsbuild once does generate a single .js bundle. :uberjar profile already has :optimizations :advanced option set in:
:uberjar {:source-paths ["env/prod/clj"]
                       :hooks [leiningen.cljsbuild]
                       :env {:production true}
                       :omit-source true
                       :aot :all
                       :main calc-pack.server
                       :cljsbuild {:builds {:app
                                            {:source-paths ["env/prod/cljs"]
                                             :compiler
                                             {:optimizations :advanced
                                              :pretty-print false}}}}}
Apparently, it wasn't working properly because of errors in my own code.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With