Search code examples
clojureclojurescriptcljsbuild

ClojureScript's separate builds for multipage web app


I have a web app that uses Clojure on backend and ClojureScript on frontend, and it consists of several pages, each requiring appropriate builded js file.

Now I know that cljsbuild can build separate builds (if specified in :builds section of config file), provided that each build has it's own folder.

Problem is: now I need to duplicate some shared code in each folder in order to build properly. Besides, it's really annoying that I have to create whole new folder for even trivial cljs file to be used, not to mention editing every time the :builds section of my project.clj.

So, it's 2016, and all the tutorials on ClojureScript I've seen so far, are for single-page applications. Are there any resources or best practices for what I'm looking for, am I missing something out?

How do I use ClojureScript in standard multi-page Clojure-stack web app?

Thanks.


Solution

  • The :modules compiler option can be used to split your clojurescript build into optimized modules that can be required on demand.