I ran into this with fonts. They have to go in priv too. I actually had to put fonts in both priv and assets to get them to work, but Phoenix docs on directory structure say to put them in priv.
Actually all static assets like css, js and images are picked up from the `priv` folder. For CSS and JS the build tool like webpack or esbuild automatically copies the CSS and JS to priv (it might also do additional tasks like minify the CSS, etc). We can also configure the build tool to copy images, like for example webpack has a copy plugin which just copies files from a source to a target directory without any processing, this can be used to automatically copy images from `assets/images` to `priv/static/images`. That way we just deal with the `assets/images` folder and never have to manually copy stuff into priv. For me `priv` is like the `.build` directory but for assets, ideally I want the build tool to deal with it and I just do stuff in the `assets` directory only.
how can i get the static path trough ~p sigil?
Like this:
In phoenix 1.7 we can now do this: thanks to verified routes (the ~p sigil)
I ran into this with fonts. They have to go in priv too. I actually had to put fonts in both priv and assets to get them to work, but Phoenix docs on directory structure say to put them in priv.
Yeah, I never remember where to put things. I figured I'd just make this as a reference!
Actually all static assets like css, js and images are picked up from the `priv` folder. For CSS and JS the build tool like webpack or esbuild automatically copies the CSS and JS to priv (it might also do additional tasks like minify the CSS, etc).
We can also configure the build tool to copy images, like for example webpack has a copy plugin which just copies files from a source to a target directory without any processing, this can be used to automatically copy images from `assets/images` to `priv/static/images`. That way we just deal with the `assets/images` folder and never have to manually copy stuff into priv.
For me `priv` is like the `.build` directory but for assets, ideally I want the build tool to deal with it and I just do stuff in the `assets` directory only.
Amazing comment, Arpan. Ty!
Aaaaah, so that's why this confused me in the past. SOME things get copied and not others.
It never made sense to me.