Phoenix - route not found for GET / static / js / some.js

I am moving the rails application to the phoenix framework.

I added some javascript (let's say some.js ) and css files to web/static/js and web/static/css dir.

<%= static_path(@conn, "/js/some.js") %> on the first page of page/index.html.eex does not work. He raised an 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 did I miss? I thought the asset pipeline worked as one on rails that automatically compiled resources.

The following are my phoenix 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"}, ... 
+7
javascript elixir phoenix-framework brunch
source share
1 answer

If you want to include a Javascript file for precompilation, you will need to add the following line of code.

Add your Javascript file to the web/static/js directory.

In web/static/js/app.js specify your file

 import "./some-file" 
+1
source share

All Articles