Fl4m3Ph03n1x

Fl4m3Ph03n1x

Add folder to mix assets.deploy

Background

I have a project that has a folder for image it uses. I call this folder images.

Issue

Usually when I do mix assets.deploy from the root of my project everything is compiled and phoenix puts the images it needs inside priv/static/.

However, these images are not being used in templates nor in renders. They are being used by elixir-desktop. So because of this when I use mix assets.deploy these images are not bundled together with everything else.

Question

I have read the introduction to deployment guide: Introduction to Deployment — Phoenix v1.8.8

But it does not address my issue. Is there a configuration I can change to add my images folders? I believe this would have to go into mix.exs or something amongst those lines.

Marked As Solved

LostKobrakai

LostKobrakai

It used to, but hasn’t been since 1.6 – based on the generated setup of a fresh phoenix install.

Also Liked

derpycoder

derpycoder

As @LostKobrakai pointed out, mix assets.deploy just processes js/css from assets folder.

Rest of the images, svgs, icons, robots.txt, canary.txt, ads.txt, favicon, etc, you need to place them directly priv/static folder.

I guess, it just minifies, compresses and generates file hash on js/css files.

However the images are compressed by us, so they are directly placed in priv/static folder and the mix assets.deploy works on those images in place:


Excerpt from Introduction to Deployment:

This step is required only if you have compilable assets like JavaScript and stylesheets. By default, Phoenix uses esbuild but everything is encapsulated in a single mix assets.deploy task defined in your mix.exs.

And that is it! The Mix task by default builds the assets and then generates digests with a cache manifest file so Phoenix can quickly serve assets in production.


P.S. I fumbled in the beginning as well, but I just saw existing projects by other people and figured out that you just leave images and such in priv/static folder.

derpycoder

derpycoder

Yup, it’s a good practice.

Let me find an official documentation.


As @LostKobrakai mentioned, it’s a new way of doing it after webpack was removed!


Note running mix phx.digestwill create digested files for all of the assets in priv/static , so your images and fonts are still cache-busted.

Last Post!

derpycoder

derpycoder

Yup, it’s a good practice.

Let me find an official documentation.


As @LostKobrakai mentioned, it’s a new way of doing it after webpack was removed!


Note running mix phx.digestwill create digested files for all of the assets in priv/static , so your images and fonts are still cache-busted.

Where Next?

Popular in Questions Top

electic
Hi, I am new to Elixir. I am trying to use the DateTime component to insert a date into MySQL however the there seems to be no way to fo...
New
vertexbuffer
Hello, can anybody help here..? I have a list of players and I what to delete an element, but every for loop the list is reverting to ori...
New
hariharasudhan94
I would like to know what is the best IDE for elixir development?
New
gshaw
What is the idiomatic way of matching for not nil in Elixir? E.g., First way: defp halt_if_not_signed_in(conn, signed_in_account) when...
New
sergio_101
I am VERY much an elixir newbie. I have taken one elixir course and one phoenix course on Udemy. During that course, I saw the instructor...
New
aalberti333
As the title describes, I’m trying to run Enum.map() over a list of key/value pairs, where the value is a map. My data looks like this: ...
New
dblack
I’ve got an issue with an app and I’ve no idea of how to troubleshoot it. I’m hoping someone here might have seen something similar. I p...
New

Other popular topics Top

Brian
What is the proper way to load a module from a file in to IEX? In the python world, doing something like this pretty standard: from ....
New
dokuzbir
I want to highlight html closing tags when i click a html tag. That works in .html files but doesnt work for html.eex templates. How can...
New
Darmani72
If I have a post route which an argument: post /my_post_route/:my_param1, MyController.my_post_handler How would get the post params ...
New
bsollish-terakeet
Credo is smart enough to check for (something like) this: assert length(the_list) == 0 with this response: Checking if an enum is empt...
New
shijith.k
I am trying to start a new phoenix project with elixir 1.9, but mix phx.new does not work. It says that ** (Mix) The task "phx.new" could...
New
sergio
Kind of like when jquery came out, it was super necessary. Existing drag and drop libraries have a bunch of baggage to support old browse...
New

We're in Beta

About us Mission Statement