将 Flask 与烧瓶资产(来自 webassets)一起使用,我按照文档为 css 压缩器编写了自己的自定义过滤器。它似乎不起作用:
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'
)
该类在启动时被调用两次,过滤器是通过它的名字找到的,但input()
似乎output()
永远不会被调用。创建了 css 文件,但显然没有任何压缩。这个事情谁有经验?