Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Concatenate multiple CSS files into one

Tags:

css

What is the best way to concatenate multiple CSS files into one CSS file?

I want to reduce the following ..

<link href="css/1.css" rel="stylesheet" type="text/css" media="all">
<link href="css/2.css" rel="stylesheet" type="text/css" media="all">
<link href="css/3.css" rel="stylesheet" type="text/css" media="all">

.. into ..

<link href="css/1-3.css" rel="stylesheet" type="text/css" media="all">

Simply doing cat css/*.css > css/1-3.css does not seem to do the trick.

like image 995
knorv Avatar asked Feb 03 '10 14:02

knorv


1 Answers

As long as the ordering of the arguments for cat matches the original ordering of the three referenced CSS files in the HTML file the cat-method should work as expected.

So given say ..

<link href="css/one.css" rel="stylesheet" type="text/css" media="all">
<link href="css/two.css" rel="stylesheet" type="text/css" media="all">
<link href="css/three.css" rel="stylesheet" type="text/css" media="all">

.. the following concaternation ..

cat css/one.css css/two.css css/three.css > css/all.css

.. together will the following reference ..

<link href="css/all.css" rel="stylesheet" type="text/css" media="all">

.. should be 100 % identical.

like image 134
knorv Avatar answered Sep 25 '22 22:09

knorv