Moritz Onken > Plack-Middleware-Assets-0.0.2 > Plack::Middleware::Assets

Download:
Plack-Middleware-Assets-0.0.2.tar.gz

Dependencies

Annotate this POD

Website

View/Report Bugs
Module Version: v0.0.2   Source   Latest Release: Plack-Middleware-Assets-1.0.0

NAME ^

Plack::Middleware::Assets - Concatenate and minify JavaScript and CSS files

VERSION ^

version 0.0.2

SYNOPSIS ^

  # 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.

DESCRIPTION ^

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.

The concatented and minified content is cached in memory.

DEVELOPMENT MODE ^

 $ 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.

CONFIGURATIONS ^

files

Files to concatenate.

minify

Boolean to indicate whether to minify or not. Defaults to 1.

type

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.

expires

Time in seconds from now (i.e. time) until the resource expires.

TODO ^

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.

SEE ALSO ^

Catalyst::Plugin::Assets

Inspired by Plack::Middleware::JSConcat

AUTHOR ^

Moritz Onken

COPYRIGHT AND LICENSE ^

This software is Copyright (c) 2011 by Moritz Onken.

This is free software, licensed under:

  The (three-clause) BSD License
syntax highlighting: