NAME

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

VERSION

version 0.0.1

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 concatented content is held in memory.

DEVELOPMENT MODE

$ plackup app.psgi

$ starman -E development app.psgi

In development mode the minification is disabled and 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.

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.

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