[英]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. 我有一个在后端使用Clojure和在前端使用ClojureScript的Web应用程序,它由几个页面组成,每个页面都需要适当的构建js文件。
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. 现在我知道cljsbuild可以构建单独的构建(如果在: config文件的build部分中指定),前提是每个构建都有自己的文件夹。
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.
除此之外,我必须为即使是简单的cljs文件创建全新的文件夹,更不用说每次我的project.clj的:builds部分都要编辑。
So, it's 2016, and all the tutorials on ClojureScript I've seen so far, are for single-page applications. 所以,它是2016年,到目前为止,我所见过的关于ClojureScript的所有教程都是针对单页应用程序的。 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? 如何在标准的多页Clojure堆栈Web应用程序中使用ClojureScript?
Thanks. 谢谢。
:modules
编译器选项可用于将clojurescript构建拆分为可根据需要提供的优化模块。
Do you really need multiple cljs builds? 你真的需要多个cljs构建吗?
Can't you just create a single one, export
ing the components you need and hooking them up into dom whenever they are needed? 难道你不能只创建一个,
export
你需要的组件,并在需要时将它们连接到dom中吗?
It may be as easy as using require
from one namespace into another. 它可能就像从一个命名空间到另一个命名空间使用
require
一样容易。
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
. 你可能
require
从命名空间中的东西page1.subnamespace
从内page2
。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.