The Perl Toolchain Summit needs more sponsors. If your company depends on Perl, please support this very important event.

NAME

Mojolicious::Plugin::AssetPack::Pipe::Reloader - Automatically reload assets in browser

SYNOPSIS

Application

  $app->plugin(AssetPack => {pipes => ["Reloader"]);

Template

  %= asset "reloader.js" if app->mode eq "development"

DESCRIPTION

Mojolicious::Plugin::AssetPack::Pipe::Reloader is a pipe which will create an asset called "reloader.js". This asset will automatically reload the page in the browser when one of the assets change on disk. This is done without the need of morbo.

This feature is EXPERIMENTAL, UNSTABLE and only meant to be used while developing.

ENVIRONNMENT

MOJO_ASSETPACK_RELOAD_STRATEGY

The environment variable MOJO_ASSETPACK_RELOAD_STRATEGY can either be set to "document" or "inline". "document" means that the whole document should reload when an asset change, while "inline" will try to figure out which "link" and "script" tags that changed and only reload those.

The default is "document" for now, but this might change in the future.

ATTRIBUTES

input

  $hash = $self->input;

Holds a mapping between the input topic and the list of input assets.

watch

  $hash = $self->watch;

Holds a mapping between the input topic and the files on disk to watch.

METHODS

before_process

This method builds up "input" and "watch".

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

new

Used to add a special "reloader.js" asset and a "/mojo-assetpack-reloader-ws" WebSocket endpoint.

process

This method does nothing.

SEE ALSO

Mojolicious::Plugin::AssetPack.