The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.

NAME

Mojolicious::Plugin::AssetPack::Pipe::ExportToDirectory

VERSION

version 0.001003

SYNOPSIS

  use Mojolicious::Lite;
  
  # "Export" comes last!
  plugin AssetPack => {pipes => [qw(... ExportToDirectory)]};
  app->asset->pipe('ExportToDirectory')->export_dir("/some/path/in/webroot");
  # app->asset->pipe('ExportToDirectory')->use_checksum_subdir(0);

DESCRIPTION

Mojolicious::Plugin::AssetPack::Pipe::ExportToDirectory will export the processed assets to the given directory so you can have them served directly by your webserver instead of going through the Mojolicious app. Note that when using a webserver like Nginx or Apache as reverse proxy, these can also be configured to cache the data they receive from your app so after answering the first request follow-up requests will usually not get through to your app.

NAME

Mojolicious::Plugin::AssetPack::Pipe::ExportToDirectory - Export processed assets to directory

ATTRIBUTES

export_dir

  $dir_path = $self->export_dir;
  $self = $self->export_dir("/path/to/some/dir");

Sets the base directory the assets will be exported to. If you do not configure this, the environment variable MOJO_ASSETPACK_EXPORT_DIRECTORY will be used as fallback. If neither value is available, processing will fail with an exception (die()).

use_checksum_subdir

  $bool = $self->use_checksum_subdir;
  $self = $self->use_checksum_subdir(0);

Controls how the exported assets are named.

By default and by setting this to a true value, assets will be exported to "<export_dir>/<checksum>/<name>.<format>". This corresponds to the route the asset-helper generates by default.

Alternatively you can set use_checksum_subdir to false in which case the assets will be exported as "<export_dir>/<name>-<checksum>.<format>". This way, you can have a better overview of the exported files and their versions.

store_gzip_variant

  $bool = $self->store_gzip_variant;
  $self = $self->store_gzip_variant(1);

Defaults to false. If set to a true value, a second export file will be generated for every asset with the same name as the default one plus the extension '.gz'. It will contain a gzipped version of the asset.

This is intended to be used with, e.g., the ngx_http_gzip_static_module of Nginx which can send pre-compressed files instead of compressing requested resources on the fly.

METHODS

process

See "process" in Mojolicious::Plugin::AssetPack::Pipe.

SEE ALSO

Mojolicious::Plugin::AssetPack.

AUTHOR

Heiko Jansen <hjansen@cpan.org>

COPYRIGHT AND LICENSE

This software is copyright (c) 2017 by Heiko Jansen <hjansen@cpan.org>.

This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.