0

I'm about to tidy up some CSS files. The stylesheets are pretty messed up and some selectors appear all over the script. I already used the css comb grunt task to tidy up the properties within the selectors but now I'm looking for something to merge and sort the selectors. I already checked out the cssc grunt plugin and it has kind of what I'm looking for. It's option parameters sortSelectors, sortDeclarations, consolidateViaDeclarations, consolidateViaSelectors and consolidateMediaQueries do the job. But unfortunately they "mess up" the code and remove comments, whitespaces, linebreaks etc.

I'm not looking for a uglifier/minifier - I'm looking for something to sort the code and make it more readable. Is there any option or another tool that could do that?

user2718671
  • 2,866
  • 9
  • 49
  • 86
  • Questions asking us to suggest, find or recommend a book, tool, software library, tutorial or other off-site resource are off-topic for Stack Overflow Stack Overflow – Paulie_D Apr 15 '16 at 11:24
  • I don't get it. you want to `beautify` or `minify`? – Aziz Apr 15 '16 at 11:30
  • @Aziz: No, I create a minified version of it later. I want a clean css file to develop with. I don't want a file where I have the same selector several times all over the script with possible double declarations. For example if I have a selector #wrapper.a_class #my_selector and elsewhere in the script #wrapper.another_class #my_selector I want those selectors nearby in the stylesheet – user2718671 Apr 15 '16 at 11:35
  • Possible duplicate of [Tools to optimize (remove redundancy and merge) CSS?](http://stackoverflow.com/questions/12451354/tools-to-optimize-remove-redundancy-and-merge-css) – Aziz Apr 15 '16 at 11:43
  • It's not a duplicate - my problem is more specific I'd say. It's just about sorting the selectors... – user2718671 Apr 15 '16 at 11:52
  • Then please provide a sample code and expected "optimized" result. – Aziz Apr 16 '16 at 10:54

0 Answers0