Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Concatenate and minify JavaScript and CSS files

branch: master

This branch is 0 commits ahead and 0 commits behind master

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 lib
Octocat-spinner-32 t
Octocat-spinner-32 Changes
Octocat-spinner-32 README.pod
Octocat-spinner-32 dist.ini
README.pod

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

Something went wrong with that request. Please try again.