Situation
I’m trying to troubleshoot why some CSS markup is not appearing in my production build. I would like to run the production version of my phoenix application on my laptop to see the final CSS file being served so I can further troubleshoot the situation.
I’m following the docs along but I’m stuck understanding how do I access it in my browser.
Have a look at your config/prod.exs that is the config your build would use for ports, domain name etc.
If you are have having CSS issues, don’t need to rebuild your phoenix app, have a look at the browser with devtools on your prod website. If CSS class is there, is the html there and correct? if css classes are not there then:
It is likely your npm install, deploy for prod or mix phx.digest didn’t go as expected.
During production the purgecss rips out unused css and it seems to be removing too much so I’m trying to debug it.
Feedback loop
My approach is to modify the Webpack file settings and then I want to run production and see what changes happen to the production version.
I’m not expert in Webpack + postcss + purgecss + scss.
Question:
Do I need to run mix phx.digest on my local machine first, check it into git and then deploy it to a service like Heroku OR does a service like Heroku run mix phx.digest on my behalf part of the deployment?
I am not either, so I don’t trust purgecss to do the right thing with all the .eex, leex, .sface syntax in both sigil form or stand alone file; it make me really uncomfortable. So my css setup is a little bit unusual. I don’t use tailwind’s utility class directly in my code at all; In stead, I made my semantic classes with tailwind’s utility classes then put them in the component layer; then go ahead to purge the whole utility layer.
Possible. My way is more explicit in that all the CSS classes I use are written by me. I only use tailwind/postcss as a css macro library/processor to write my classes in a concise way.
All css packages I have used in the past are notoriously bad in backward compatibility. Say I upgrade tailwind from version 1.x to 2.x, many things will stop working. Had I use their classes directly, some of my element will lost style and it is hard to find out which and fix them. With my indirect way, the build will fail so it is easier to fix.
exactly. Without purge, tailwind is humongous. But I don’t trust purge. So I gave purge nothing, therefore it will purge everything except the things I protected explicitly in the component layer.
@cenotaph You are correct. This is what I should be doing to troubleshoot the situation. I don’t need to be running in production mode. Thanks for the tip.