2 ms·
The last time I try to play with it, I got stuck on 2 things that seem basic: - Couldn’t serve a static folder! Like I had a folder of js/img that I wanted to
by hartator 4y ago
The last time I try to play with it, I got stuck on 2 things that seem basic:
- Couldn’t serve a static folder! Like I had a folder of js/img that I wanted to serve as is, didn’t want to transform into anything, it was super difficult to do.
- Couldn’t find an easy way to inspect or debug a live pipe.
It was a while ago so maybe things have improved a lot. However it kind of left a sour taste in my mouth when asking for help, I was told static folder is not really the scope of the framework and things in the like.
- unvs 4y agoIn your generated `my_app_web/endpoint.ex` there is a plug that will serve static contents from your `priv/static` directory: https://github.com/phoenixframework/phoenix/blob/master/installer/templates/phx_web/endpoint.ex#L16-L24 https://github.com/phoenixframework/phoenix/blob/master/inst... This points to a function in `my_app_web.ex` which specifies which paths it will serve: https://github.com/phoenixframework/phoenix/blob/master/installer/templates/phx_single/lib/app_name_web.ex#L20 https://github.com/phoenixframework/phoenix/blob/master/inst... So you can either copy your js and image folders to `priv/static/assets` and they will be available as `localhost:port/assets/js/somefile.js` etc. OR you can add `js` to the list of paths to serve in app_name_web.ex and copy your js files to `priv/static/js` and access them at `localhost:port/js/somefile.js`.