Created
March 31, 2017 09:09
-
-
Save davidcraig/9c01f3d6e6d88253544f03915851f12e to your computer and use it in GitHub Desktop.
PHP: CSS Asset Pipeline
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
$files = [ | |
// Insert Files Here | |
]; | |
$str = ''; | |
function combine_file_contents($filename, $str) | |
{ | |
if (file_exists($filename)) { | |
$str .= file_get_contents($filename) . "\r\n"; | |
return $str; | |
} else { | |
return $str; | |
} | |
} | |
foreach($files as $style) { | |
$str = combine_file_contents($style, $str); | |
} | |
$ETag = sha1($str); | |
/* Set Headers */ | |
header('Content-Type: text/css'); | |
header('ETag: ' . $ETag); | |
/* Output CSS */ | |
echo $str; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Simply add css files you wish to source into the $files array, then you can <link rel="stylesheet" src="css.php" type="text/css" />