w0lf42
w0lf42

Reputation: 528

CSS Combine Files & Compress

I want to be able to, at build-time, submit a group of CSS files and have the following done:

I'm sure there are others, but this what I'm starting with.

This is the preference order of how I would like to access the tool:

  1. Remote Website
  2. Web Hosted Installed - same as my website (Debian/PHP 5.2.12)
  3. Local Machine Installed (Windows 7)

I saw CSS Compressor, but it doesn't seem to combine CSS files nor does it combine overlapping CSS selectors.

Thanks in advance.

Upvotes: 5

Views: 5348

Answers (3)

SMK
SMK

Reputation: 1

You should use sCSSOptimizer.

  • Example

If you want to compile more than one css files than do like this

<?php
require('./sCSSOptimizer/scssoptimizer.class.php');

$css1 = file_get_contents("./cssfile1.css");
$css2 = file_get_contents("./cssfile2.css");

$final_css = $css1.$css2; //you can join more, if you want...

$scss = new sCSSOptimizer($final_css);

//$compression_rate = $scss->getCompressionRate();

$compressed_css = $scss->getOptimized();
//do your stuff
?>

.

Upvotes: 0

Jonathan Moffatt
Jonathan Moffatt

Reputation: 13457

You could try Chirpy. It will combine and compress files and v2 has a command line interface.

I've only ever run it within Visual Studio though.

Upvotes: 0

Martin
Martin

Reputation: 38289

I would recommend the YUI compressor since it is widely used and has a command line interface.

You should also consider making your build process automated so that you can build everything with a single command. If you don't want to use an existing build tool you could create a short .bat file for this kind of task.


First, combine your files:

type file1.css file2.css file3.css > combined.css

then pass it to the YUI compressor:

java -jar yuicompressor.jar combined.css > combined-min.css

Upvotes: 4

Related Questions