Plack::Middleware::Assets - Concatenate and minify JavaScript and CSS files
version 0.0.2
# in app.psgi use Plack::Builder; builder { enable "Assets", files => [<static/js/*.js>]; enable "Assets", files => [<static/css/*.css>], minify => 0; $app; }; # $env->{'psgix.assets'}->[0] points at the first asset.
Plack::Middleware::Assets concatenates JavaScript and CSS files and minifies them. A md5 digest is generated and used as unique url to the asset. The Last-Modified header is set to the mtime of the most recently changed file. The Expires header is set to one month in advance. Set "expires" to change the time of expiry.
md5
Last-Modified
mtime
Expires
The concatented and minified content is cached in memory.
$ plackup app.psgi $ starman -E development app.psgi
In development mode the minification is disabled and the concatenated content is regenerated if there were any changes to the files.
Files to concatenate.
Boolean to indicate whether to minify or not. Defaults to 1.
1
Type of the asset. Either css or js. This is derived automatically from the file extensions but can be set explicitly if you are using non-standard file extensions.
css
js
Time in seconds from now (i.e. time) until the resource expires.
time
Allow to concatenate documents from URLs, such that you can have a Plack::Middleware::File::Sass that converts SASS files to CSS and concatenate those with other CSS files. Also concatenate content from CDNs that host common JavaScript libraries.
Catalyst::Plugin::Assets
Inspired by Plack::Middleware::JSConcat
Moritz Onken
This software is Copyright (c) 2011 by Moritz Onken.
This is free software, licensed under:
The (three-clause) BSD License
To install Plack::Middleware::Assets, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::Assets
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::Assets
For more information on module installation, please visit the detailed CPAN module installation guide.