Asif Shiraz
Asif Shiraz

Reputation: 874

How to serve static assets from custom folders in phoenix

I want to use ckeditor in my phoenix project.

If I place ckeditor files in /web/static/assets/ckeditor, the ckeditor folder gets copied to /priv/static, but if I access the file at http://localhost:4000/ckeditor/ckeditor.js it shows me a

no route found for GET /ckeditor/ckeditor.js

However, if I move the whole of ckeditor folder underneath a folder of the standard name (js, css, image) then it gets served.

The static assets documentation http://www.phoenixframework.org/docs/static-assets suggested that anything placed there would be copied over and served. But seems like only js/css/image/font folders are getting served, not any custom named folder.

How can I have these files be served?

Upvotes: 9

Views: 4141

Answers (1)

Kevin Rockwood
Kevin Rockwood

Reputation: 199

Take a look at the Plug.Static config in lib/YOUR_APP/endpoint.ex

Here's the default:

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

You can add additional folders to the only list and they'll be served as well.

Upvotes: 18

Related Questions