phoenix-framework - 如何从phoenix中的自定义文件夹提供静态 Assets

标签 phoenix-framework

我想在我的凤凰项目中使用ckeditor。

如果将ckeditor文件放在/web/static/assets/ckeditor中,则ckeditor文件夹将被复制到/priv/static,但是如果我在http://localhost:4000/ckeditor/ckeditor.js中访问该文件,则会显示一个

no route found for GET /ckeditor/ckeditor.js



但是,如果我将整个ckeditor文件夹移到标准名称(js,css,image)的文件夹下,则可以使用它。

静态 Assets 文档http://www.phoenixframework.org/docs/static-assets建议将放置在其中的所有内容复制并提供。但是似乎只提供js/css/image/font文件夹,而不提供任何自定义命名文件夹。

如何提供这些文件?

最佳答案

看看lib/YOUR_APP/endpoint.ex中的Plug.Static配置

这是默认值:

plug Plug.Static,
  at: "/"
  only: ~w(css fonts images js sitemaps favicon.ico robots.txt)

您可以将其他文件夹添加到only列表中,它们也将被提供。

关于phoenix-framework - 如何从phoenix中的自定义文件夹提供静态 Assets ,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38176422/

相关文章:

elixir - 您如何为 ueberauth 身份进行单独的注册回调

elixir - 为什么我没有为#Ecto.Query 实现协议(protocol) Enumerable?

elixir - Phoenix 中如何创建 View 属性?

elixir - 更改 Phoenix 中运行时的依赖关系

Elixir 将模块的引用作为函数参数传递

reactjs - 将远程客户端连接到 Phoenix channel

postgresql - 将 Dockerized 应用程序连接到本地 Redis 和 Postgresql

elixir - insert_all 不匹配类型 :utc_datetime

postgresql - 如何通过 SSL 从 Phoenix Web App 连接到 PostgreSQL?

logging - 灵药/Phoenix : How to customize HTTP request log format?