Using Flask with flask-assets (from webassets) I wrote my own custom filter for a css compressor, following the documentation. It doesn't seem to work:
from csscompressor import compress
from flask_assets import Bundle
from webassets.filter import Filter, register_filter
class NoopFilter(Filter):
name = 'csscompressor'
print("noopfilter")
def output(self, _in, out, **kwargs):
print("output")
def input(self, _in, out, **kwargs):
print("input")
register_filter(NoopFilter)
bundles = {
'home_css': Bundle(
'css/main.css',
'css/forms.css',
output='gen/home.css',
filters='csscompressor'
)
The class is called twice on startup and the filter is found by it's name, but input()
or output()
seem never to be called. The css file is created, but obviously without any compression. Does anyone have experience with this?
Apparently, it was a caching issue. Changing the filter name made it work. Hopefully, this helps someone pulling their hair out over a few kB.