简体   繁体   中英

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.

:modules编译器选项可用于将clojurescript构建拆分为可根据需要提供的优化模块。

Do you really need multiple cljs builds?

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

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 .

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM