For various reasons [multisite/performance/boost], I'm using Minify [http://code.google.com/p/minify/] on my site rather than using Core to handle CSS compression.
One way of using Minify is to pass it a string of CSS urls, in the form of
<link rel="stylesheet" type="text/css" href="/min/?f=modules/node/node.css,modules/system/defaults.css,...">
I've been doing this by using a preprocess function in template.php to assemble the css files into a string.
However, the better way to do it is by creating a file that just comprises an array in the form of
<?php return array( 'css'=>array('//modules/node/node.css','//modules/system/defaults.css',...), 'print'=>array('//sites/all/themes/mytheme/css/print.css'), ); ?>
and calling this like:
<link rel="stylesheet" type="text/css" href="/min/?g=css" media="all"> <link rel="stylesheet" type="text/css" href="/min/?g=print" media="print">
I can create this by using a theme function that assembles the array and writes it to the file. However, writing to a file every time the page is called is an obvious overhead. Leaving the file static and updating it manually, however, means that if a new or updated module adds a new CSS file, I probably won't know about it and won't update the array.
So my actual question is: in my theme, or in my custom module, is there anything I can hook into so that I write to this file only when the cache is cleared (which happens when modules are added/updated right?). I guess it would need to be in my custom module as I wouldn't be using my theme when the cache is actually cleared (as I use garland for administration) - but then how does a module know what css a theme is using?
The hacky way would be to get the theme to write to the file if there's a GET variable something like ?css_rewrite or run a cron job every few hours, but I wondered if there was anything more elegant.
--David Hart.