我有一个小型Flask应用程序,我想使用一些ClojureScript来增强客户端的用户体验。
现在我无法通过烧瓶提供clojurescript,因为路径混乱了。
Flask断言像Javascript脚本这样的静态文件位于目录static
中。我已经更改了project.clj
,以便将编译目标放在那里:
:output-to "static/plot.js"
:output-dir "static"
不幸的是,加载此文件时,无法使用goog.require
加载相关文件:
"ClojureScript could not load :main, did you forget to specify :asset-path?"
我认为缺少的是路径中的前导/static
而不是static
。
我可以为leiningen cljsbuild或clojurescript指定一个前缀吗?
答案 0 :(得分:5)
您需要在已编译的选项中指定:asset-path
(如错误消息所示)。来自https://github.com/clojure/clojurescript/wiki/Compiler-Options#asset-path
使用:main时,由于Web服务器的配置,通常需要控制入口点脚本尝试加载脚本的位置。 :asset-path是相对URL路径,而不是文件系统路径。
:asset-path "assets/js"