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

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

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

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

and then create the js file in web/static/js/test.js.

However, I received an error message test.jsnot found in the browser console.

I noticed that there is a folder priv/static/js, and I'm trying to create a js file in priv/static/js/test.js.

This time the error has disappeared.

I am really confused about this.

What is the difference between web/staticand priv/static? If I need to test my static files in a development environment, where should I put static files? and what about the production environment?

Thank.

+4
1

Priv/static . I. . , Brunch, /.  http://www.phoenixframework.org/docs/static-assets

+3

Source: https://habr.com/ru/post/1673750/


All Articles