Some frameworks (e.g. Ruby on Rails) give you support for these alternatives out-of-the-box, but in the land of less opinionated software things can require a bit more work. Since I am personally a fan of the Pyramid web framework, I’ve used the pyramid_webassets and pyramid_fanstatic packages in the past to provide this support. However, these packages are so powerful and comprehensive that they can also tend to be somewhat involved in regards to configuration, so I recently decided to roll my own Pyramid add-on: pyramid_assetmutator
Although definitely not as “feature-full” as the packages I have mentioned earlier, as of this writing it provides the following:
- Support for piping (a.k.a “mutating”) assets through pretty much any command you like (its core functionality is quite rudimentary).
- The ability to specify whether to have your assets “mutated” during each request, or on each “application boot” (typically best for prod setups).
- A unified Python 2/3 codebase.