What is the different between web/static and priv/static in phoenix?

北城余情 提交于 2020-01-13 11:29:13

问题


I am new to elixir and phoenix. Now I have trouble with the static assets in phoenix.

I want to add a js file in my page, and I add the following code in my template:

<script src="<%= static_path(@conn, "/js/test.js") %>"></script>

and then create a js file at web/static/js/test.js.

However, I got the error about test.js is not found in the browser's console.

I notice there is a priv/static/js folder, and I try to create the js file at priv/static/js/test.js.

This time, the error gone.

I am really confuse about this.

What is the different between web/static and priv/static ? If I need to test my static files in develop environment, where should I put the static files? and how about the production environment ?

Thanks.


回答1:


Priv/static contains processed and concatenated files. I.e they will be saved in this folder after the compilation. However check if your Brunch is working as it takes files from web/static. For better understanding i recommend you go through the doc http://www.phoenixframework.org/docs/static-assets



来源:https://stackoverflow.com/questions/43151504/what-is-the-different-between-web-static-and-priv-static-in-phoenix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!