I am migrating my rails application to phoenix framework.
I added some javascript (say some.js
) and css files to web/static/js
and web/static/css
dir.
<%= static_path(@conn, "/js/some.js") %>
in the front page page/index.html.eex
didn't work. It raised the exception (dev env):
Phoenix.Router.NoRouteError at GET /static/js/some.js
no route found for GET /static/js/some.js (VisualTrader.Router)
If I copied some.js
to priv/static/js
dir, it worked. So what I missed? I thought the assets pipeline worked like the one in rails, which auto precompiled resources.
Below list my phoenix framework environments:
Elixir version
elixir -v
Erlang/OTP 18 [erts-7.1] [source] [64-bit] [smp:4:4] [async-threads:10] [hipe] [kernel-poll:false]
Elixir 1.3.0-dev (187f4f8)
Phoenix version
defp deps do
[{:phoenix, "~> 1.1.2"},
...
If you want to include the Javascript File to be precompiled you'd need to add the following line of code.
Add your Javascript file in web/static/js
directory.
In web/static/js/app.js
include your file
import "./some-file"
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With