We work on the Magento platform and our front-end developers all work on the same CSS stylesheet. There are a lot of existing styles that come with this stylesheet. Most of the time I tell them to put any additional styles at the bottom to make it easier for merging and everything. This doesn't always work when you want put certain styles with selectors that are already existing in the stylesheet.
We seem to be having a lot of issues with developers not managing conflicts correctly and overriding other peoples code. Obviously its always best to try and work on files when you know others are done with it to lessen the chance of conflicts but obviously if there is more then one developer working on a site and there is only one CSS file this is going to run into a lot of conflicts.
I am looking for ways other people manage this and some ideas for how to best minimize the amount of conflicts these developers have.
Taking all these factors into consideration, your best bet is probably to have a single global CSS file (including styles used on multiple pages), and if any of your pages use a lot of unique styles, load an extra CSS file in addition to the main one on those pages.
Yes, It is possible to include one CSS file in another and it can be done multiple times. Also, import multiple CSS files in the main HTML file or in the main CSS file. It can be done by using @import keyword.
CSS can be applied to HTML or XHTML using three methods: linked, embedded, and inline. In the linked method, the CSS is stored in a separate file, instead of directly in the HTML page. In the embedded method, CSS is stored as part of the HTML page, in the header section.
Don't have a single CSS file. Have a bunch of small CSS files that are merged and minified into a single file for deployment but that logically separate styles during development.
As @JosephMastey suggests below, I personally separate one file per differently-styled page of the site. Within stylesheets I tend to order selectors from more-general to more specific, and group selectors together (e.g. all table#foo ...
selectors are contiguous).
Use a sane version-control system like Git that does not require you to check out or lock files, but instead allows simultaneous edits with intelligent merges.
Edit: And at some point you have train and trust your developers. The only method that will ultimately help with developers who are repeatedly running over each others' work and merging their edits badly is teaching them not to do so.
Your chance of edit conflicts increases dramatically if everyone's editing the same part of the file (namely, the end).
I'd say let the CSS go where it goes naturally. If someone's editing one part and someone else is editing a whole other section, any decent revision control system will merge most of the changes automatically when someone updates, and there will be fewer conflicts.
I concur on the "Don't have a single CSS file" sentiment. Magento modules can each have their own stylesheet(s), and of course you already separate unrelated tasks into independent modules don't you? I would prefer it if Magento came with separate sheets for catalog, checkout, customer, etc. but sadly it does not, you'll have to do that yourself and maybe prepare a blank theme with them.
It doesn't make sense to break it up according to developers. Devs come and go and are assigned different tasks.
Magento also includes CSS & JS merging so you don't need to worry about having many sheets. There is Fooman Speedster and mod_pagespeed as well.
In my experience, a single developer should be working on the project until it matures enough to allow for outside help. That single developer should set guidelines and standard styles to be used throughout the application, so that people need not add a new style for each element. Try and have the initial developer review all new stylesheet changes as they're added to the repository initially, so that developers that are new to the project are made aware of utility classes, or conventions, that exist.
It would also help if you had some kind of stock system theme that you always start with -- that way people know the score at the start of each project and have no excuse to mess up your organised CSS :)
As @cHao points out, when a whole bunch of developers get involved make sure they never add directly to the end of the file. That's the single biggest cause of conflicts that we experience and can be easily avoided.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With