【问题标题】:How do I put my JS file on the top-level?如何将我的 JS 文件放在顶层?
【发布时间】:2017-04-03 20:55:21
【问题描述】:

我正在使用 service worker 尝试 phoenix,但我需要将 js 文件放在顶层。以localhost:4000/sample.js为例。

【问题讨论】:

    标签: elixir phoenix-framework brunch


    【解决方案1】:

    在顶层提供静态资产。只需将文件添加到 web/static/assets 并将该静态文件(即 sample.js)添加到应用程序端点中 Plug.Static 的 only 选项中,例如:

    # => ./lib/my_app/endpoint.ex
    plug Plug.Static,
    at: "/", from: :learn_phoenix, gzip: false,
    only: ~w(css fonts images js favicon.ico robots.txt sample.js) #=> added sample.js to this list. fonts, images, css and js are all directories
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多