3 ms·
In your generated `my_app_web/endpoint.ex` there is a plug that will serve static contents from your `priv/static` directory: https://github.com/phoenixframewo
by unvs 4y ago
In 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`.