[Catalyst] Minify JS/CSS and server as static files
Mike Raynham
catalyst at mikeraynham.co.uk
Sun Jul 31 18:37:28 GMT 2011
These might get you started:
Catalyst::View::JavaScript::Minifier::XS
and
Catalyst::View::CSS::Minifier::XS
http://search.cpan.org/~frew/Catalyst-View-JavaScript-Minifier-XS-2.101000/lib/Catalyst/View/JavaScript/Minifier/XS.pm
http://search.cpan.org/~frew/Catalyst-View-CSS-Minifier-XS-2.000000/lib/Catalyst/View/CSS/Minifier/XS.pm
On 31/07/11 19:17, Pavel Karoukin wrote:
> Hello,
>
> 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!
>
> Regards,
> Pavel
More information about the Catalyst
mailing list