简体   繁体   中英

Phoenix.Router.NoRouteError for assets

in elixir i try to create project under umbrella with this command

mix phx.new my_project --umbrella

in apps directory try to install phoenix project with this command

mix phx.new phx_project --no-ecto

and trye to add assets with new structure under the assets directory and new file with bar.css and use it on front end with :

<%= Routes.static_path(@conn, "/ja/bee/foo/bar.css") %>

I got nothing found.

but with this

<%= Routes.static_path(@conn, "/css/app.css") %>

it's ok .

In your endpoint.ex file, you will have a section that looks something like

  plug Plug.Static,
    at: "/", from: :attendance_web, gzip: false,
    only: ~w(css fonts images js favicon.ico robots.txt)

You will need to add the ja directory to the list in the :only key. Then make sure your ja directory is beside your css directory.

I tried to put my assets (js, css, images) under the assets directory but the real place, it is in fact under the assets/static directory. Personally I think this is not a good place why? Because in assets directory we have directories like css, js directory.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM