compiled .css files not pushed in repo
Hello everyone, I was adviced to not push my dist folder with .css files , infact I added the folder in a .gitignore but css style from my webpage is not showing now.
Can anyone advice me what to do because I think I got that wrong …
Ps. I created another folder with the main.css file and a script in a json that allows me to copy the changes from dist/main.css to css/main.css
13 Replies
You should have a build command set up in your hosting provider. This allows you to keep your dist/ in your .gitignore
I added the folder later on in the .gitignore because I had already pushed the dist previously .
I just can’t understand the goal of that 😭
You don't need the compiled code in your repo unless you are trying to serv it
Typically you don't push the dist/ because it's a large folder filled with the output of your build command.
It saves space in your repo if you include everything that's needed to build and you provide the build command so people who fork your repo can build it locally.
Same idea with your hosting provider. Gitignore your dist/ repo and give the build command to your hosting provider so it knows how to build the files and serve an optimized, working version of your website
additionally, in a team you'd have someone approve any pulls to your main branch, and those built files would just be double work
Sidenote: Not all hosting works this way 😄
Good to know because I only use Netlify 🤣
yea I know you only know the Netlify way xD
tbf the hosting that doesn't work that way is hosting where you can just run the build step yourself, generally
and you likely still shouldn't include generated code, even if that means you have a slightly more manual deploy
Do you think it was a good idea to copy the main.css in another folder and push it? I’d run a script to copy any changes made to the files with that
no point if you have teh uncompiled code there already
again unless you want to serv the .css files (host them) then no reason to include the build/dist in your repo.
your hosting provider should have instructions on how to deploy if you have a build step, you should follow those and keep your generated CSS files out of the repo
Perfect, thank you so much for your help guys, I will try to inform myself better about this matter !