gpt4 book ai didi

clojurescript - 如何避免 cljsbuild 项目中的重复?

转载 作者:行者123 更新时间:2023-12-01 05:12:40 24 4
gpt4 key购买 nike

:cljsbuild我的 project.clj 部分有很多重复:

:cljsbuild {
:builds {:dev {:source-paths ["src-cljs"]
:compiler {:output-dir "resources/public/js"
:output-to "resources/public/js/main.js"
:optimizations :whitespace
:pretty-print true
:source-map "resources/public/js/main.map"
:language-in :ecmascript5
:foreign-libs [{:file "third-party/mutation-summary/mutation-summary.js"
:provides ["MutationSummary"]}]}}
:production {:source-paths ["src-cljs"]
:compiler {:output-to "resources/public/js/main-min.js"
:optimizations :advanced
:pretty-print false
:language-in :ecmascript5
:foreign-libs [{:file "third-party/mutation-summary/mutation-summary.js"
:provides ["MutationSummary"]}]}}
:test {:source-paths ["src-cljs" "test-cljs"]
:compiler {:output-to "resources/private/js/unit-test.js"
:optimizations :whitespace
:pretty-print true
:language-in :ecmascript5
:preamble ["react/react.min.js"]
:externs ["react/externs/react.js"]
:foreign-libs [{:file "third-party/mutation-summary/mutation-summary.js"
:provides ["MutationSummary"]}]}}}
:test-commands {"unit-tests" ["slimerjs" :runner
"resources/private/js/unit-test.js"]}}

我确信一定可以使用配置文件来消除这种重复,但我的 Leiningen fu 缺乏。

最佳答案

一个不太漂亮但可行的解决方案是添加 defdefn在您的上方 defproject保存您正在重用的标准参数,例如:(未进行拼写检查或功能示例)

(def defaults
"Returns default compiler options"
{:language-in :ecmascript5
:foreign-libs [{:file "third-party/mutation-summary/mutation-summary.js"
:provides ["MutationSummary"]}]})

然后到 merge带有自定义值的映射:

 :builds {:dev {:source-paths ["src-cljs"]
:compiler (merge defaults {:pretty-print true})

关于clojurescript - 如何避免 cljsbuild 项目中的重复?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/23455749/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com