Jack Tang
Jack Tang

Reputation: 181

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

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.eexdidn'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:

Upvotes: 8

Views: 3298

Answers (1)

Ronak Jain
Ronak Jain

Reputation: 1783

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"

Upvotes: 1

Related Questions