Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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.

like image 628
user2331095 Avatar asked Oct 17 '22 14:10

user2331095


1 Answers

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

like image 194
Zubair Nabi Avatar answered Oct 21 '22 05:10

Zubair Nabi