Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How do I configure plug to set another directory as public other than priv/static/?

I'm currently using aurelia as my front end framework for my phoenix app. I would like to designate the jspm_packages folder in the root of my project as a static directory in addition to the priv/static folder. Is there a way to configure plug to do this?

like image 718
Korbin Avatar asked Oct 20 '22 04:10

Korbin


1 Answers

The short answer is: you should not.

The long answer is: in production, Elixir applications care about two directories: 1. ebin (which is where you put compiled code) and 2. priv (auxiliary files that you need to run your software in production, like static files). If you rely on a file that is not in any of those directories, things can break when running in production or building releases. So I would advise you to move the aurelia stuff inside priv/static or have a tool that compiles aurelia artifacts to priv/static at the end of the day.

If you don't want to do that, the "I have warned you" alternative is here: http://hexdocs.pm/plug/Plug.Static.html. You can set from: "." when configuring Plug.Static in your Phoenix endpoint at lib/my_app/endpoint.ex. You can also plug more than one Plug.Static if you want.

like image 129
José Valim Avatar answered Oct 31 '22 18:10

José Valim