.\" Automatically generated by Pod::Man 4.07 (Pod::Simple 3.32) .\" .\" Standard preamble: .\" ======================================================================== .de Sp \" Vertical space (when we can't use .PP) .if t .sp .5v .if n .sp .. .de Vb \" Begin verbatim text .ft CW .nf .ne \\$1 .. .de Ve \" End verbatim text .ft R .fi .. .\" Set up some character translations and predefined strings. \*(-- will .\" give an unbreakable dash, \*(PI will give pi, \*(L" will give a left .\" double quote, and \*(R" will give a right double quote. \*(C+ will .\" give a nicer C++. Capital omega is used to do unbreakable dashes and .\" therefore won't be available. \*(C` and \*(C' expand to `' in nroff, .\" nothing in troff, for use with C<>. .tr \(*W- .ds C+ C\v'-.1v'\h'-1p'\s-2+\h'-1p'+\s0\v'.1v'\h'-1p' .ie n \{\ . ds -- \(*W- . ds PI pi . if (\n(.H=4u)&(1m=24u) .ds -- \(*W\h'-12u'\(*W\h'-12u'-\" diablo 10 pitch . if (\n(.H=4u)&(1m=20u) .ds -- \(*W\h'-12u'\(*W\h'-8u'-\" diablo 12 pitch . ds L" "" . ds R" "" . ds C` "" . ds C' "" 'br\} .el\{\ . ds -- \|\(em\| . ds PI \(*p . ds L" `` . ds R" '' . ds C` . ds C' 'br\} .\" .\" Escape single quotes in literal strings from groff's Unicode transform. .ie \n(.g .ds Aq \(aq .el .ds Aq ' .\" .\" If the F register is >0, we'll generate index entries on stderr for .\" titles (.TH), headers (.SH), subsections (.SS), items (.Ip), and index .\" entries marked with X<> in POD. Of course, you'll have to process the .\" output yourself in some meaningful fashion. .\" .\" Avoid warning from groff about undefined register 'F'. .de IX .. .if !\nF .nr F 0 .if \nF>0 \{\ . de IX . tm Index:\\$1\t\\n%\t"\\$2" .. . if !\nF==2 \{\ . nr % 0 . nr F 2 . \} .\} .\" ======================================================================== .\" .IX Title "Mojolicious::Plugin::AssetPack 3pm" .TH Mojolicious::Plugin::AssetPack 3pm "2017-01-29" "perl v5.24.1" "User Contributed Perl Documentation" .\" For nroff, turn off justification. Always turn off hyphenation; it makes .\" way too many mistakes in technical documents. .if n .ad l .nh .SH "NAME" Mojolicious::Plugin::AssetPack \- Compress and convert css, less, sass, javascript and coffeescript files .SH "VERSION" .IX Header "VERSION" 1.39 .SH "SYNOPSIS" .IX Header "SYNOPSIS" .SS "Application" .IX Subsection "Application" .Vb 1 \& use Mojolicious::Lite; \& \& # Load plugin and pipes in the right order \& plugin AssetPack => { \& pipes => [qw(Less Sass Css CoffeeScript Riotjs JavaScript Combine)] \& }; \& \& # define asset \& app\->asset\->process( \& # virtual name of the asset \& "app.css" => ( \& \& # source files used to create the asset \& "sass/bar.scss", \& "https://github.com/Dogfalo/materialize/blob/master/sass/materialize.scss", \& ) \& ); .Ve .SS "Template" .IX Subsection "Template" .Vb 6 \& \& \& %= asset "app.css" \& \& <%= content %> \& .Ve .SH "FOR EXISTING USERS" .IX Header "FOR EXISTING USERS" Are you already using AssetPack? You can still do so without any change. This new version was written to make it easier to maintain and also easier to extend. The new code will be \*(L"activated\*(R" by loadind this plugin with a list of pipes: .PP .Vb 1 \& $app\->plugin(AssetPack => {pipes => [...]}); .Ve .PP The old \s-1API\s0 require Mojolicious::Plugin::AssetPack::Backcompat to be installed. .SH "DESCRIPTION" .IX Header "DESCRIPTION" Mojolicious::Plugin::AssetPack is Mojolicious plugin for processing static assets. The idea is that JavaScript and \s-1CSS\s0 files should be served as one minified file to save bandwidth and roundtrip time to the server. .PP There are many external tools for doing this, but integrating them with Mojolicious can be a struggle: You want to serve the source files directly while developing, but a minified version in production. This assetpack plugin will handle all of that automatically for you. .PP The actual processing is delegated to \*(L"pipe objects\*(R". Please see \&\*(L"Pipes\*(R" in Mojolicious::Plugin::AssetPack::Guides::Tutorial for a complete list. .SH "GUIDES" .IX Header "GUIDES" .IP "\(bu" 2 Mojolicious::Plugin::AssetPack::Guides::Tutorial .Sp The tutorial will give an introduction to how AssetPack can be used. .IP "\(bu" 2 Mojolicious::Plugin::AssetPack::Guides::Cookbook .Sp The cookbook has various receipes on how to cook with AssetPack. .SH "ENVIRONMENT" .IX Header "ENVIRONMENT" It is possible to set environment variables to change the behavior of AssetPack: .IP "\(bu" 2 \&\s-1MOJO_ASSETPACK_DEBUG\s0 .Sp Set this environment variable to get more debug to \s-1STDERR.\s0 Currently you can set it to a value between 0 and 3, where 3 provides the most debug. .IP "\(bu" 2 \&\s-1MOJO_ASSETPACK_LAZY\s0 .Sp Set this environment variable if you want to delay processing the assets until they are requested. This can be very useful while developing when the assets are changed frequently. .SH "OPTIONAL MODULES" .IX Header "OPTIONAL MODULES" There are some optional modules you might want to install: .IP "\(bu" 2 CSS::Minifier::XS .Sp Used by Mojolicious::Plugin::AssetPack::Pipe::Css. .IP "\(bu" 2 CSS::Sass .Sp Used by Mojolicious::Plugin::AssetPack::Pipe::Sass. .IP "\(bu" 2 IO::Socket::SSL .Sp Required if you want to download assets served over \s-1SSL.\s0 .IP "\(bu" 2 JavaScript::Minifier::XS .Sp Used by Mojolicious::Plugin::AssetPack::Pipe::JavaScript. .SH "HELPERS" .IX Header "HELPERS" .SS "asset" .IX Subsection "asset" .Vb 4 \& $self = $app\->asset; \& $self = $c\->asset; \& $bytestream = $c\->asset($topic, @args); \& $bytestream = $c\->asset("app.css", media => "print"); .Ve .PP \&\f(CW\*(C`asset()\*(C'\fR is the main entry point to this plugin. It can either be used to access the Mojolicious::Plugin::AssetPack instance or as a tag helper. .PP The helper name \*(L"asset\*(R" can be customized by specifying \*(L"helper\*(R" when registering the plugin. .PP See Mojolicious::Plugin::AssetPack::Guides::Tutorial for more details. .SH "ATTRIBUTES" .IX Header "ATTRIBUTES" .SS "minify" .IX Subsection "minify" .Vb 2 \& $bool = $self\->minify; \& $self = $self\->minify($bool); .Ve .PP Set this to true to combine and minify the assets. Defaults to false if \&\*(L"mode\*(R" in Mojolicious is \*(L"development\*(R" and true otherwise. .PP See \*(L"Application mode\*(R" in Mojolicious::Plugin::AssetPack::Guides::Tutorial for more details. .SS "route" .IX Subsection "route" .Vb 2 \& $route = $self\->route; \& $self = $self\->route($route); .Ve .PP A Mojolicious::Routes::Route object used to serve assets. The default route responds to \s-1HEAD\s0 and \s-1GET\s0 requests and calls \&\fIserve_asset()\fR on \*(L"store\*(R" to serve the asset. .PP The default route will be built and added to the application when \*(L"process\*(R" is called the first time. .PP See \*(L"\s-1ASSETS FROM CUSTOM DOMAIN\*(R"\s0 in Mojolicious::Plugin::AssetPack::Guides::Cookbook for an example on how to customize this route. .SS "store" .IX Subsection "store" .Vb 2 \& $obj = $self\->store; \& $self = $self\->store(Mojolicious::Plugin::AssetPack::Store\->new); .Ve .PP Holds a Mojolicious::Plugin::AssetPack::Store object used to locate, store and serve assets. .SS "tag_for" .IX Subsection "tag_for" .Vb 2 \& $self = $self\->tag_for(sub { my ($asset, $c, \e%args, @attrs) = @_; }); \& $code = $self\->tag_for; .Ve .PP Holds a sub reference that returns a Mojo::Bytestream object containing the markup required to render an asset. .PP \&\f(CW$asset\fR is a Mojolicious::Plugin::AssetPack::Asset object, \f(CW$c\fR is an Mojolicious::Controller object and \f(CW@attrs\fR can contain a list of \&\s-1HTML\s0 attributes. \f(CW%args\fR currently contains: .IP "\(bu" 4 base_url .Sp See \*(L"\s-1ASSETS FROM CUSTOM DOMAIN\*(R"\s0 in Mojolicious::Plugin::AssetPack::Guides::Cookbook. .IP "\(bu" 4 topic .Sp Name of the current topic. .SS "ua" .IX Subsection "ua" .Vb 1 \& $ua = $self\->ua; .Ve .PP Holds a Mojo::UserAgent which can be used to fetch assets either from local application or from remote web servers. .SH "METHODS" .IX Header "METHODS" .SS "pipe" .IX Subsection "pipe" .Vb 2 \& $obj = $self\->pipe($name); \& $obj = $self\->pipe("Css"); .Ve .PP Will return a registered pipe by \f(CW$name\fR or \f(CW\*(C`undef\*(C'\fR if none could be found. .SS "process" .IX Subsection "process" .Vb 2 \& $self = $self\->process($topic => @assets); \& $self = $self\->process($definition_file); .Ve .PP Used to process assets. A \f(CW$definition_file\fR can be used to define \f(CW$topic\fR and \f(CW@assets\fR in a seperate file. See \&\*(L"Process assets\*(R" in Mojolicious::Plugin::AssetPack::Guides::Tutorial for more details. .PP \&\f(CW$definition_file\fR defaults to \*(L"assetpack.def\*(R". .SS "processed" .IX Subsection "processed" .Vb 1 \& $collection = $self\->processed($topic); .Ve .PP Can be used to retrieve a Mojo::Collection object, with zero or more Mojolicious::Plugin::AssetPack::Asset objects. Returns undef if \f(CW$topic\fR is not defined with \*(L"process\*(R". .SS "register" .IX Subsection "register" .Vb 1 \& $self\->register($app, \e%config); .Ve .PP Used to register the plugin in the application. \f(CW%config\fR can contain: .IP "\(bu" 2 helper .Sp Name of the helper to add to the application. Default is \*(L"asset\*(R". .IP "\(bu" 2 pipes .Sp This argument is mandatory and need to contain a complete list of pipes that is needed. Example: .Sp .Vb 1 \& $app\->plugin(AssetPack => {pipes => [qw(Sass Css Combine)]); .Ve .Sp See \*(L"Pipes\*(R" in Mojolicious::Plugin::AssetPack::Guides::Tutorial for a complete list of available pipes. .IP "\(bu" 2 proxy .Sp A hash of proxy settings. Set this to \f(CW0\fR to disable proxy detection. Currently only \*(L"no_proxy\*(R" is supported, which will set which requests that should bypass the proxy (if any proxy is detected). Default is to bypass all requests to localhost. .Sp See \*(L"detect\*(R" in Mojo::UserAgent::Proxy for more infomation. .SH "SEE ALSO" .IX Header "SEE ALSO" \&\*(L"\s-1GUIDES\*(R"\s0, Mojolicious::Plugin::AssetPack::Asset, Mojolicious::Plugin::AssetPack::Pipe and Mojolicious::Plugin::AssetPack::Store. .SH "COPYRIGHT AND LICENSE" .IX Header "COPYRIGHT AND LICENSE" Copyright (C) 2014, Jan Henning Thorsen .PP This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0. .SH "AUTHOR" .IX Header "AUTHOR" Jan Henning Thorsen \- \f(CW\*(C`jhthorsen@cpan.org\*(C'\fR .PP Alexander Rymasheusky .PP Mark Grimes \- \f(CW\*(C`mgrimes@cpan.org\*(C'\fR .PP Per Edin \- \f(CW\*(C`info@peredin.com\*(C'\fR .PP Viktor Turskyi