5

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.

4

3 回答 3

2

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

于 2016-06-08T03:40:06.547 回答
0

Do you really need multiple cljs builds?

Can't you just create a single one, exporting the components you need and hooking them up into dom whenever they are needed?

于 2016-06-01T12:08:52.793 回答
0

It may be as easy as using require from one namespace into another.

For instance, say that you have the following structure :

project ├── src │   └── cljs │   ├── page1 │   ├── page2 │   │  

You could require things from the namespace page1.subnamespace from inside page2.

于 2016-06-03T12:58:54.283 回答