[Catalyst] Minify JS/CSS and server as static files

Trevor Leffler tleffler at uw.edu
Mon Aug 1 16:22:07 GMT 2011


If you've a build process, that can also be a good time to create 
minified versions of css/js, pre-process templates, etc. so that 
everything is how you want it for your production environment.

--Trevor


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
> 
> _______________________________________________
> List: Catalyst at lists.scsys.co.uk
> Listinfo: http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/catalyst
> Searchable archive: http://www.mail-archive.com/catalyst@lists.scsys.co.uk/
> Dev site: http://dev.catalyst.perl.org/



More information about the Catalyst mailing list