Mojolicious::Plugin::AutoReload - Automatically reload open browser windows when your application changes
version 0.010
use Mojolicious::Lite; plugin AutoReload => {}; get '/' => 'index'; app->start; __DATA__ @@ index.html.ep Hello world!
This plugin automatically reloades the page when the Mojolicious webapp restarts. This is especially useful when using the Morbo development server, which automatically restarts the webapp when it detects changes. Combined, morbo and Mojolicious::Plugin::AutoReload will automatically display your new content whenever you change your webapp in your editor!
morbo
Mojolicious::Plugin::AutoReload
This works by opening a WebSocket connection to a specific Mojolicious route. When the server restarts, the WebSocket is disconnected, which triggers a reload of the page.
The AutoReload plugin will automatically add a <script> tag to your HTML pages while running in development mode. If you need to control where this script tag is written, use the "auto_reload" helper.
<script>
development
To disable the plugin for a single page, set the plugin.auto_reload.disable stash value to a true value:
plugin.auto_reload.disable
get '/' => sub { my ( $c ) = @_; # Don't auto-reload the home page $c->stash( 'plugin.auto_reload.disable' => 1 ); ... };
The auto_reload template helper inserts the JavaScript to automatically reload the page. This helper only works when the application mode is development, so you can leave this in all the time and have it only appear during local development.
auto_reload
This is only needed if you want to control where the <script> for automatically-reloading is rendered.
This plugin adds a /auto_reload WebSocket route to your application.
/auto_reload
Mojolicious
Thanks to Grant Street Group for funding continued development of this plugin!
Doug Bell <preaction@cpan.org>
Robert DeRose <RobertDeRose@users.noreply.github.com>
Zeeshan Muhammad <zeeshan@dkhr.com>
This software is copyright (c) 2018 by Doug Bell.
This is free software; you can redistribute it and/or modify it under the same terms as the Perl 5 programming language system itself.
To install Mojolicious::Plugin::AutoReload, copy and paste the appropriate command in to your terminal.
cpanm
cpanm Mojolicious::Plugin::AutoReload
CPAN shell
perl -MCPAN -e shell install Mojolicious::Plugin::AutoReload
For more information on module installation, please visit the detailed CPAN module installation guide.