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.08
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       Note that the main author have moved on to using
47       Mojolicious::Plugin::Webpack instead, which uses
48       <https://webpack.js.org/> under the hood, but is just as convenient to
49       use as this plugin. It is very easy to try out
50       Mojolicious::Plugin::Webpack, since it will detect your AssetPack based
51       project automatically, and migrate them over to webpack once the plugin
52       is loaded.
53
54       There are many external tools for doing this, but integrating them with
55       Mojolicious can be a struggle: You want to serve the source files
56       directly while developing, but a minified version in production. This
57       assetpack plugin will handle all of that automatically for you.
58
59       Your application creates and refers to an asset by its topic (virtual
60       asset name).  The process of building actual assets from their
61       components is delegated to "pipe objects". Please see "Pipes" in
62       Mojolicious::Plugin::AssetPack::Guides::Tutorial for a complete list.
63

BREAKING CHANGES

65   assetpack.db (v1.47)
66       "assetpack.db" no longer track files downloaded from the internet. It
67       will mostly "just work", but in some cases version 1.47 might download
68       assets that have already been downloaded with AssetPack version 1.46
69       and earlier.
70
71       The goal is to remove "assetpack.db" completely.
72

GUIDES

74       · Mojolicious::Plugin::AssetPack::Guides::Tutorial
75
76         The tutorial will give an introduction to how AssetPack can be used.
77
78       · Mojolicious::Plugin::AssetPack::Guides::Developing
79
80         The "developing" guide will give insight on how to do effective
81         development with AssetPack and more details about the internals in
82         this plugin.
83
84       · Mojolicious::Plugin::AssetPack::Guides::Cookbook
85
86         The cookbook has various receipes on how to cook with AssetPack.
87

HELPERS

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

ATTRIBUTES

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

METHODS

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

SEE ALSO

201       Mojolicious::Plugin::Webpack.
202
203       "GUIDES", Mojolicious::Plugin::AssetPack::Asset,
204       Mojolicious::Plugin::AssetPack::Pipe and
205       Mojolicious::Plugin::AssetPack::Store.
206
208       Copyright (C) 2014, Jan Henning Thorsen
209
210       This program is free software, you can redistribute it and/or modify it
211       under the terms of the Artistic License version 2.0.
212

AUTHOR

214       Jan Henning Thorsen - "jhthorsen@cpan.org"
215
216       Alexander Rymasheusky
217
218       Mark Grimes - "mgrimes@cpan.org"
219
220       Per Edin - "info@peredin.com"
221
222       Viktor Turskyi
223
224
225
226perl v5.30.1                      2020-01-30 Mojolicious::Plugin::AssetPack(3)
Impressum