Compile production assets with figwheel

We currently use cljsbuild to compile our clojurescript source into the assets used in production (and testing), but during development, we use lein-figwheel. Both cljsbuild and figwheel are constantly watching for changes of the source and recompile when necessary.

I was wondering, whether it’s possible to use just one tool for both, preferably in the same process. We’re fine with switching tools, especially Figwheel Main. Each file change should just compile:

  • a js with advanced optimizations to be used in production
  • live reload the code in the browser as figwheel & figwheel main do it

I found this in the figwheel documentation, but it requires manual work like cleaning targets and running the build on demand with special options.

Thanks a lot!

As a data point, figwheel main works great for me to build production assets (along with a short wrapper script that removes target/ just to be safe as you say)

Good to hear. You compile them on change or on demand?

I work continuously using a dev build. Prod builds are built on demand or on in CI

it’s strange that you want to build optimized version of your app on every change, why is that?

We have some integration tests using RSpec, Capybara & headless Chrome, that also test ClojureScript parts (along with the Rails application). As we want to run them both on CI and locally, it was an easy solution. But maybe we should rethink that.

might be out of the topic but I want to suggest to give shadow-cljs a spin see if there’s any feature you need in your specific case.