> There are still many open design problems, but should those be solved, is there any interest in having this functionality in the Mojolicious core distribution?
Since there appears to be quite a bit of interest in this feature, here are some of the design problems that still need to be solved and are on top of my list atm.
1) How should pre-filters work that need to be applied to the indovidual source files before they are concatenated? These would mostly be compilers, like our EP renderer, CoffeeScript, Sass and the like.
- The most popular solution so far would be a nested data structure that represents the entire pipeline.
asset 'app.js' => [['*.js.ep' => 'ep'], '*.js'] => 'jsmin';
- An alternative would be recursive assets.
asset 'coffee.js' => ['*.coffee'] => 'coffeescript';
asset 'app.js' => ['*.js', 'coffee.js'] => 'jsmin';
2) Where should the asset source files be stored? This is a bit tricky since we need to share the DATA section with the static dispatcher and renderer.
- Most popular solution here is to just consider all static files and templates potential asset source files indiscriminately. Their extensions would only be used for finding (like in the glob above), but would have no meaning attached otherwise, MIME types are based on the target file and filters on the pipeline. A big advantage would be that we can access all static files and templates shipping with plugins for example.
3) How should we decide which filters are only necessary for production and should be disabled during development?
- A simple blacklist is currently the most popular solution here.
app->pipeline->development_filters([qw(ep coffeescript sass)]);
- Alternatively we could also split all filters into categories, like compressors and compilers.
4) What should be the name of the helper (and possibly Mojolicious::Lite keyword)? While "asset" sounds pretty good it might get confused with our existing Mojo::Asset classes and related methods.
- We have no alternative name for it yet. The pipeline class will be called Mojolicious::Pipeline, and everything will refer to it as "the asset pipeline".