serving static assets in a subfolder other than the defaults

1,086 views
Skip to first unread message

kevin thompson

unread,
Jul 8, 2015, 4:44:17 PM7/8/15
to phoeni...@googlegroups.com
Purely as a learning exercise, I'm trying to serve up a reveal.js page using phoenix. The steps seem pretty simple, I create the app, download the dependencies, etc.

Then I go into /priv/static and I delete everything that was created there.

Next, I take all the content from the reveal.js git page (https://github.com/hakimel/reveal.js) and I copy it into /priv/static.

Finally, I copied the index.html file to /web/templates/layout/app.html.eex and run mix phoenix.server.

When I visit the page, I see that all of the static assets that are in a subfolder called /lib do not load. For example, the page gets a 404 for http://localhost:4000/lib/js/head.min.js However the other stuff on the page loads fine. So this might be a silly question, but will Phoenix not serve static assets that are in a folder which is not named js, images, or css? The documentation for static assets implies that whatever is in that folder should be available. I didn't see any exceptions or special configuration required.

Kevin

Chris McCord

unread,
Jul 8, 2015, 4:49:18 PM7/8/15
to phoeni...@googlegroups.com
you need to add the /priv/static/* folders you want to expose to the `:only` option to Plug.Static in endpoint.ex. We expose js, css, images, and robots.txt by default. You should be able to add /lib and be all set.
--
You received this message because you are subscribed to the Google Groups "phoenix-talk" group.
To unsubscribe from this group and stop receiving emails from it, send an email to phoenix-talk...@googlegroups.com.
To post to this group, send email to phoeni...@googlegroups.com.
Visit this group at http://groups.google.com/group/phoenix-talk.
To view this discussion on the web visit https://groups.google.com/d/msgid/phoenix-talk/b19ec33f-23ee-4ade-b3ac-9783ebb9ddbb%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

kevin thompson

unread,
Jul 8, 2015, 5:10:14 PM7/8/15
to phoeni...@googlegroups.com
Awesome, Chris, thank you. That worked for me. It looks like at one time there was a documentation page on static assets (http://www.phoenixframework.org/v0.7.2/docs/static-assets) but there isn't one for the current version of the framework. I'm just wondering where I should have looked to find this answer.

Kevin

You received this message because you are subscribed to a topic in the Google Groups "phoenix-talk" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/phoenix-talk/jOKj8Myy5nc/unsubscribe.
To unsubscribe from this group and all its topics, send an email to phoenix-talk...@googlegroups.com.

To post to this group, send email to phoeni...@googlegroups.com.
Visit this group at http://groups.google.com/group/phoenix-talk.
Reply all
Reply to author
Forward
0 new messages