如何在烧瓶上提供 clojurescript
How to serve clojurescript over flask
我有一个小型 Flask 应用程序,我想使用一些 ClojureScript 来增强客户端的用户体验。
现在我无法通过 Flask 提供 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
。
我可以为那些 inlcudes 指定带有 leiningen cljsbuild 或 clojurescript 的前缀吗?
您需要在编译选项中指定 :asset-path
(如错误消息所示)。来自 https://github.com/clojure/clojurescript/wiki/Compiler-Options#asset-path
When using :main it is often necessary to control where the entry point script attempts to load scripts from due to the configuration of the web server. :asset-path is a relative URL path not a file system path.
:asset-path "assets/js"
我有一个小型 Flask 应用程序,我想使用一些 ClojureScript 来增强客户端的用户体验。
现在我无法通过 Flask 提供 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
。
我可以为那些 inlcudes 指定带有 leiningen cljsbuild 或 clojurescript 的前缀吗?
您需要在编译选项中指定 :asset-path
(如错误消息所示)。来自 https://github.com/clojure/clojurescript/wiki/Compiler-Options#asset-path
When using :main it is often necessary to control where the entry point script attempts to load scripts from due to the configuration of the web server. :asset-path is a relative URL path not a file system path.
:asset-path "assets/js"