.\" Automatically generated by Pod::Man 4.14 (Pod::Simple 3.40)
.\"
.\" 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
..
.nr rF 0
.if \n(.g .if rF .nr rF 1
.if (\n(rF:(\n(.g==0)) \{\
. if \nF \{\
. de IX
. tm Index:\\$1\t\\n%\t"\\$2"
..
. if !\nF==2 \{\
. nr % 0
. nr F 2
. \}
. \}
.\}
.rr rF
.\" ========================================================================
.\"
.IX Title "Mojolicious::Plugin::AssetPack 3"
.TH Mojolicious::Plugin::AssetPack 3 "2020-01-30" "perl v5.30.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"
2.08
.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 "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
Note that the main author have moved on to using
Mojolicious::Plugin::Webpack instead, which uses
under the hood, but is just as convenient to use as
this plugin. It is very easy to try out
Mojolicious::Plugin::Webpack, since it will detect your AssetPack
based project automatically, and migrate them over to webpack once the plugin
is loaded.
.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
Your application creates and refers to an asset by its topic (virtual asset
name). The process of building actual assets from their components is
delegated to \*(L"pipe objects\*(R". Please see
\&\*(L"Pipes\*(R" in Mojolicious::Plugin::AssetPack::Guides::Tutorial for a complete list.
.SH "BREAKING CHANGES"
.IX Header "BREAKING CHANGES"
.SS "assetpack.db (v1.47)"
.IX Subsection "assetpack.db (v1.47)"
\&\f(CW\*(C`assetpack.db\*(C'\fR no longer track files downloaded from the internet. It will
mostly \*(L"just work\*(R", but in some cases version 1.47 might download assets that
have already been downloaded with AssetPack version 1.46 and earlier.
.PP
The goal is to remove \f(CW\*(C`assetpack.db\*(C'\fR completely.
.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::Developing
.Sp
The \*(L"developing\*(R" guide will give insight on how to do effective development with
AssetPack and more details about the internals in this plugin.
.IP "\(bu" 2
Mojolicious::Plugin::AssetPack::Guides::Cookbook
.Sp
The cookbook has various receipes on how to cook with AssetPack.
.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
\&\fBserve_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"
Deprecated. Use \*(L"renderer\*(R" in Mojolicious::Plugin::AssetPack::Asset instead.
.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 separate 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 information.
.SH "SEE ALSO"
.IX Header "SEE ALSO"
Mojolicious::Plugin::Webpack.
.PP
\&\*(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