Plack::Middleware::Compile
version 0.01
use Plack::Builder; builder { enable 'Compile' => ( pattern => qr{\.coffee$}, lib => 'coffee', blib => 'js', mime => 'text/plain', map => sub { my $filename = shift; $filename =~ s/coffee$/js/; return $filename; }, compile => sub { my ($in, $out) = @_; system("coffee --compile --stdio < $in > $out"); } ); }
Enable this middleware to serve compiled content (Coffeescript -> Javascript, Sass -> CSS, HAML -> HTML, etc). The content will only be compiled when the source is changed.
A regex which will be matched against PATH_INFO to determine if the middleware should handle this request.
A directory in which to find the source files.
An output directory to send the compiled files to. This will be the same as your lib directory if you don't specify it.
The mime type to serve the files as. Defaults to 'text/plain'.
A function that maps input filenames to output filenames.
A function that takes the input and output filenames as arguments and produces the compiled file from the input.
To install Plack::Middleware::Compile, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Plack::Middleware::Compile
CPAN shell
perl -MCPAN -e shell install Plack::Middleware::Compile
For more information on module installation, please visit the detailed CPAN module installation guide.