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::Browserify::Processor - An AssetPack processor for browserify

DESCRIPTION

Mojolicious::Plugin::Browserify::Processor is a Mojolicious::Plugin::AssetPack preprocessor.

SYNOPSIS

  use Mojolicious::Lite;

  plugin "AssetPack";
  app->asset->preprocessors->remove($_) for qw( js jsx );

  my $browserify = Mojolicious::Plugin::Browserify::Processor->new;
  app->asset->preprocessors->add($browserify);
  app->asset("app.js" => "/js/main.js");

  get "/app" => "app_js_inlined";
  app->start;

  __DATA__
  @@ app_js_inlined.js.ep
  %= asset "app.js" => {inline => 1}

See also Mojolicious::Plugin::Browserify for a simpler API.

ATTRIBUTES

browserify_args

  $array_ref = $self->browserify_args;
  $self= $self->browserify_args([ -g => "reactify" ]);

Command line arguments that will be passed on to browserify.

environment

  $str = $self->environment;
  $self = $self->environment($str);

Should be either "production" or "development" (default). This variable will be passed on as NODE_ENV to browserify.

extensions

  $array_ref = $self->extensions;
  $self = $self->extensions([qw( js jsx )]);

Specifies the extensions browserify should look for.

executable

  $path = $self->executable;

Holds the path to the "browserify" executable. Default to just "browserify". browserify can also be found in ./node_modules/.bin/browserify, in the current project directory.

METHODS

can_process

  $bool = $self->can_process;

Returns true if browserify can be executed.

checksum

  $str = $self->checksum($text, $path);

Returns the checksum for a given chunk of $text. $text is a scalar ref containing the text from the asset. The default is to use "md5_sum" in Mojo::Util.

process

Used to process the JavaScript using browserify.

COPYRIGHT AND LICENSE

Copyright (C) 2014, Jan Henning Thorsen

This program is free software, you can redistribute it and/or modify it under the terms of the Artistic License version 2.0.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org