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

NAME

Mojolicious::Plugin::AssetPack::Preprocessors - Holds preprocessors

METHODS

add

  $self->add($extension => $object);

  $self->add($extension => sub {
    my ($assetpack, $text, $file) = @_;
    $$text =~ s/foo/bar/ if $file =~ /baz/ and $assetpack->minify;
  });

Define a preprocessor which is run on a given file extension. These preprocessors will be chained. The callbacks will be called in the order they where added.

The default preprocessor defined is described under "detect".

In case of $object, the object need to be able to have the process() method.

checksum

  $str = $self->checksum($extension => \$text, $filename);

detect

Will add the following preprocessors, if they are available:

  • jsx

    JSX is a JavaScript XML syntax transform recommended for use with React. See http://facebook.github.io/react/docs/jsx-in-depth.html for more information.

    Installation on Ubuntu and Debian:

      $ sudo apt-get install npm
      $ npm install -g react-tools
  • less

    LESS extends CSS with dynamic behavior such as variables, mixins, operations and functions. See http://lesscss.org for more details.

    Installation on Ubuntu and Debian:

      $ sudo apt-get install npm
      $ sudo npm install -g less
  • sass

    Sass makes CSS fun again. Sass is an extension of CSS3, adding nested rules, variables, mixins, selector inheritance, and more. See http://sass-lang.com for more information. Supports both *.scss and *.sass syntax variants.

    Installation on Ubuntu and Debian:

      $ sudo apt-get install rubygems
      $ sudo gem install sass
  • compass

    Compass is an open-source CSS Authoring Framework built on top of "sass". See http://compass-style.org/ for more information.

    Installation on Ubuntu and Debian:

      $ sudo apt-get install rubygems
      $ sudo gem install compass

    This module will try figure out if "compass" is required to process your *.scss files. This is done with this regexp on the top level sass file:

      m!\@import\W+compass\/!;

    NOTE! Compass support is experimental.

    You can disable compass detection by setting the environment variable MOJO_ASSETPACK_NO_COMPASS to a true value.

  • js

    Javascript is minified using JavaScript::Minifier::XS. This module is optional and must be installed manually.

    EXPERIMENTAL! Not sure if this is the best minifier.

  • css

    CSS is minified using CSS::Minifier::XS. This module is optional and must be installed manually.

    EXPERIMENTAL! Not sure if this is the best minifier.

  • coffee

    CoffeeScript is a little language that compiles into JavaScript. See http://coffeescript.org for more information.

    Installation on Ubuntu and Debian:

      $ npm install -g coffee-script

process

  $self->process($extension => $assetpack, \$text, $filename);

Will run the preprocessor callbacks added by "add". The callbacks will be called with the $assetpack object as the first argument.

map_type

DEPRECATED: The mapping is already done based on input files.

remove

  $self->remove($extension);
  $self->remove($extension => $cb);

This method will remove all preprocessors defined for an extension, or just a given $cb.

AUTHOR

Jan Henning Thorsen - jhthorsen@cpan.org