[Catalyst] Minify JS/CSS and server as static files
catalyst at mikeraynham.co.uk
Sun Jul 31 18:37:28 GMT 2011
These might get you started:
On 31/07/11 19:17, Pavel Karoukin wrote:
> I am looking to develop feature in my project but want to check if
> something already exists or there is existing pattern to implement it.
> Bassically, I want in my TT templates add JS/CSS files into header. And
> in production mode I want minify/aggregate 'em and save on disc so web
> server could serve these minified and aggregated files directly.
> How I plan to do it:
> In TT layout template define array variable and all templates will be
> adding there JS/CSS they need. Then in main template I will generate
> code like:
> <link rel="stylesheet" type="text/css"
> href="/minify/css?files=path/to/file1.css;path/to/file2.css" />
> /minify/css will be action of controller minify to join and minify these
> files and save them in /static subfolder as single file. Then I need to
> configure webserver somehow to look for this file (good question - how
> to do it...) and serve it directly instead of firing catalyst action.
> Few problems tho:
> 1) How to name files to keep track of: list of files in minified file,
> their update date.
> 2) How to remove old files. (probably with cron?)
> Any ideas will be really appreciated!
More information about the Catalyst