1Mojolicious::Plugin::AsUsseetrPaCcokn(t3r)ibuted Perl DoMcoujmoelnitcaitoiuosn::Plugin::AssetPack(3)
2
3
4

NAME

6       Mojolicious::Plugin::AssetPack - Compress and convert css, less, sass,
7       javascript and coffeescript files
8

VERSION

10       2.06
11

SYNOPSIS

13   Application
14         use Mojolicious::Lite;
15
16         # Load plugin and pipes in the right order
17         plugin AssetPack => {
18           pipes => [qw(Less Sass Css CoffeeScript Riotjs JavaScript Combine)]
19         };
20
21         # define asset
22         app->asset->process(
23           # virtual name of the asset
24           "app.css" => (
25
26             # source files used to create the asset
27             "sass/bar.scss",
28             "https://github.com/Dogfalo/materialize/blob/master/sass/materialize.scss",
29           )
30         );
31
32   Template
33         <html>
34           <head>
35             %= asset "app.css"
36           </head>
37           <body><%= content %></body>
38         </html>
39

DESCRIPTION

41       Mojolicious::Plugin::AssetPack is Mojolicious plugin for processing
42       static assets. The idea is that JavaScript and CSS files should be
43       served as one minified file to save bandwidth and roundtrip time to the
44       server.
45
46       There are many external tools for doing this, but integrating them with
47       Mojolicious can be a struggle: You want to serve the source files
48       directly while developing, but a minified version in production. This
49       assetpack plugin will handle all of that automatically for you.
50
51       Your application creates and refers to an asset by its topic (virtual
52       asset name).  The process of building actual assets from their
53       components is delegated to "pipe objects". Please see "Pipes" in
54       Mojolicious::Plugin::AssetPack::Guides::Tutorial for a complete list.
55

BREAKING CHANGES

57   assetpack.db (v1.47)
58       "assetpack.db" no longer track files downloaded from the internet. It
59       will mostly "just work", but in some cases version 1.47 might download
60       assets that have already been downloaded with AssetPack version 1.46
61       and earlier.
62
63       The goal is to remove "assetpack.db" completely.
64

GUIDES

66       · Mojolicious::Plugin::AssetPack::Guides::Tutorial
67
68         The tutorial will give an introduction to how AssetPack can be used.
69
70       · Mojolicious::Plugin::AssetPack::Guides::Developing
71
72         The "developing" guide will give insight on how to do effective
73         development with AssetPack and more details about the internals in
74         this plugin.
75
76       · Mojolicious::Plugin::AssetPack::Guides::Cookbook
77
78         The cookbook has various receipes on how to cook with AssetPack.
79

HELPERS

81   asset
82         $self = $app->asset;
83         $self = $c->asset;
84         $bytestream = $c->asset($topic, @args);
85         $bytestream = $c->asset("app.css", media => "print");
86
87       "asset()" is the main entry point to this plugin. It can either be used
88       to access the Mojolicious::Plugin::AssetPack instance or as a tag
89       helper.
90
91       The helper name "asset" can be customized by specifying "helper" when
92       registering the plugin.
93
94       See Mojolicious::Plugin::AssetPack::Guides::Tutorial for more details.
95

ATTRIBUTES

97   minify
98         $bool = $self->minify;
99         $self = $self->minify($bool);
100
101       Set this to true to combine and minify the assets. Defaults to false if
102       "mode" in Mojolicious is "development" and true otherwise.
103
104       See "Application mode" in
105       Mojolicious::Plugin::AssetPack::Guides::Tutorial for more details.
106
107   route
108         $route = $self->route;
109         $self = $self->route($route);
110
111       A Mojolicious::Routes::Route object used to serve assets. The default
112       route responds to HEAD and GET requests and calls serve_asset() on
113       "store" to serve the asset.
114
115       The default route will be built and added to the application when
116       "process" is called the first time.
117
118       See "ASSETS FROM CUSTOM DOMAIN" in
119       Mojolicious::Plugin::AssetPack::Guides::Cookbook for an example on how
120       to customize this route.
121
122   store
123         $obj = $self->store;
124         $self = $self->store(Mojolicious::Plugin::AssetPack::Store->new);
125
126       Holds a Mojolicious::Plugin::AssetPack::Store object used to locate,
127       store and serve assets.
128
129   tag_for
130       Deprecated. Use "renderer" in Mojolicious::Plugin::AssetPack::Asset
131       instead.
132
133   ua
134         $ua = $self->ua;
135
136       Holds a Mojo::UserAgent which can be used to fetch assets either from
137       local application or from remote web servers.
138

METHODS

140   pipe
141         $obj = $self->pipe($name);
142         $obj = $self->pipe("Css");
143
144       Will return a registered pipe by $name or "undef" if none could be
145       found.
146
147   process
148         $self = $self->process($topic => @assets);
149         $self = $self->process($definition_file);
150
151       Used to process assets. A $definition_file can be used to define $topic
152       and @assets in a separate file. See "Process assets" in
153       Mojolicious::Plugin::AssetPack::Guides::Tutorial for more details.
154
155       $definition_file defaults to "assetpack.def".
156
157   processed
158         $collection = $self->processed($topic);
159
160       Can be used to retrieve a Mojo::Collection object, with zero or more
161       Mojolicious::Plugin::AssetPack::Asset objects. Returns undef if $topic
162       is not defined with "process".
163
164   register
165         $self->register($app, \%config);
166
167       Used to register the plugin in the application. %config can contain:
168
169       · helper
170
171         Name of the helper to add to the application. Default is "asset".
172
173       · pipes
174
175         This argument is mandatory and need to contain a complete list of
176         pipes that is needed. Example:
177
178           $app->plugin(AssetPack => {pipes => [qw(Sass Css Combine)]);
179
180         See "Pipes" in Mojolicious::Plugin::AssetPack::Guides::Tutorial for a
181         complete list of available pipes.
182
183       · proxy
184
185         A hash of proxy settings. Set this to 0 to disable proxy detection.
186         Currently only "no_proxy" is supported, which will set which requests
187         that should bypass the proxy (if any proxy is detected). Default is
188         to bypass all requests to localhost.
189
190         See "detect" in Mojo::UserAgent::Proxy for more information.
191

SEE ALSO

193       "GUIDES", Mojolicious::Plugin::AssetPack::Asset,
194       Mojolicious::Plugin::AssetPack::Pipe and
195       Mojolicious::Plugin::AssetPack::Store.
196
198       Copyright (C) 2014, Jan Henning Thorsen
199
200       This program is free software, you can redistribute it and/or modify it
201       under the terms of the Artistic License version 2.0.
202

AUTHOR

204       Jan Henning Thorsen - "jhthorsen@cpan.org"
205
206       Alexander Rymasheusky
207
208       Mark Grimes - "mgrimes@cpan.org"
209
210       Per Edin - "info@peredin.com"
211
212       Viktor Turskyi
213
214
215
216perl v5.28.1                      2018-09-02 Mojolicious::Plugin::AssetPack(3)
Impressum