cljc / lein / clojurescript成功了吗?
我以前使用过cljx,能够用cljx插件编译同一个项目,从而启动cljsbuild任务。
现在我切换到cljc,我希望将cljc文件编译成编译好的Java和javascript,以便在浏览器中使用。
这是我当前的project.clj文件
(defproject com.mysite/myproj "0.3.2-SNAPSHOT"
:description ""
:url ""
:license {:name "Gnu Lesser Public License"
:url "https://www.gnu.org/licenses/lgpl.html"}
:dependencies [[org.clojure/clojure "1.7.0"]]
:plugins [[lein-cljsbuild "1.0.3"]
[lein-localrepo "0.4.0"] ]
:source-paths ["cljc" "src" ]
:cljsbuild {:builds [{
:source-paths ["cljc" ]
:compiler {
:output-to "browser-based/js/main.js"
:optimizations :whitespace
:pretty-print true }
} ]}
:hooks [leiningen.cljsbuild]
:aot [myproj.core]
:main myproj.core)我不记得我是从哪里复制的,但是我假设leiningen.cljsbuild钩子是自动触发cljs构建过程的。但是,在删除cljx插件并转到cljc之后,它成功地编译了我的程序的Java版本,但似乎没有生成任何javascript。
发布于 2015-08-11 23:18:30
是的,很管用。
试着:
(defproject com.mysite/myproj "0.3.2-SNAPSHOT"
:description ""
:url ""
:license {:name "Gnu Lesser Public License"
:url "https://www.gnu.org/licenses/lgpl.html"}
:dependencies [[org.clojure/clojure "1.7.0"]
[org.clojure/clojurescript "1.7.28"]
:plugins [[lein-cljsbuild "1.0.6"]
[lein-localrepo "0.4.0"]]
:source-paths ["cljc" "src"]
:cljsbuild {:builds [{
:source-paths ["cljc" "src"]
:compiler {:output-to "browser-based/js/main.js"
:optimizations :whitespace
:pretty-print true}}]}
:hooks [leiningen.cljsbuild])然后运行:lein compile或lein cljsbuild once
请注意,我在:cljsbuild下将:source-paths更改为包含"src"::source-paths ["cljc" "src"]。除此之外,我还增加了对clojurescript的显式依赖,并将cljsbuild版本增加到1.0.6。
顺便问一下,为什么您有一个单独的cljc目录?您可以让cljc、clj & cljs文件共享相同的目录结构。
https://stackoverflow.com/questions/31952672
复制相似问题