We’ve had this discussion at work a while back and there’s different trains of thought for whether you should commit your generated CSS file (if you’re compiling it from SASS/SCSS/LESS etc).
When I first started at BTB I noticed that it was common to *not* include the generated CSS in the repo, which meant when you pulled a project from version control, you’d need to run npm install, gulp setup and all that gubbins before it showed correctly in the browser. The theory is, that because the css is generated, it doesn’t need to be committed, and it just causes merge problems when multiple people are working on the same project. Pulling someone else’s changes will *always* mean your generated CSS file needs to be merged.
I just click ignore in this sort of conflict, because my local running gulp task will generate a new CSS file anyway, and it won’t be a problem.
So we had a problem where the staging server, which initially was compiling the SASS itself, was using a different version of SASS, and was creating a different end result (who knew that sass could be compiled differently between versions?!), which wasn’t ideal. Things that were being fixed locally, were still broken when pulled on the staging server.
However I know that when working with purely backend programmers, they don’t want the faff of compiling it, and for it to just look as it should. So it might just be easier to commit the final, compiled CSS.
Committing the generated CSS has these advantages:
- When cloning the project on a staging server or the production server, you don’t have to compile the styles. Just something you don’t need to worry about (although you might have a deployment process that compiles the styles for you).
- When cloning the project onto a computer for someone who doesn’t care about frontend (showing a boss, or someone working on backend), they don’t have to compile the styles. Again, something you don’t have to worry about. I think it should always look like something after cloning, rather than totally broken.
For the slight inconvenience of it asking to merge the compiled file every update, I think it’s worth it.
The top picture is from Git – the simple guide, by Roger Dudler.