Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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?

like image 418
Asif Shiraz Avatar asked Jul 04 '16 03:07

Asif Shiraz


1 Answers

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.

like image 109
Kevin Rockwood Avatar answered Nov 16 '22 09:11

Kevin Rockwood