Mojolicious::Plugin::AssetPack::Manual::Modes - How AssetPack behaves in different modes


Mojolicious::Plugin::AssetPack behaves different in "production" mode than in "development" mode. The reason for this is that is't often easier to track down bugs in a given file if it's not minified and crammed into one file.


Production mode

This plugin will compress sass, less, css, javascript and coffeescript with the help of external applications on startup. The result will be one file with all the sources combined. This file is stored in "Packed directory".

The files in the packed directory will have a checksum added to the filename which will ensure broken browsers request a new version once the file is changed. Example:

  <script src="/packed/app-ed6d968e39843a556dbe6dad8981e3e0.js">

This is done using "process".

Development mode

This plugin will expand the input files to multiple script or link tags which makes debugging and development easier.

TIP! Make morbo watch your less/sass files as well:

  $ morbo -w lib -w templates -w public/sass

You can also set the MOJO_ASSETPACK_NO_CACHE environment variable to "1" to pack your assets on each request.


It is possible to instruct your application to load an old asset, if it fail to generate a new asset. This is done by setting the "fallback" in Mojolicious::Plugin::AssetPack attribute to a true value.

"add" in Mojolicious::Plugin::AssetPack will log the error if an old asset was found or throw the error if unable to.

The default value is "1" in production mode.

This feauture is EXPERIMENTAL. Feedback wanted.


Jan Henning Thorsen -