Flask-Assets扩展(使用webassets库)可以用于此目的。以下是将其配置为使用SCSS的pyScss编译器(在Python中实现)的方法:
from flask import Flask, render_templatefrom flask.ext.assets import Environment, Bundleapp = Flask(__name__)assets = Environment(app)assets.url = app.static_url_pathscss = Bundle('foo.scss', 'bar.scss', filters='pyscss', output='all.css')assets.register('scss_all', scss)并在模板中包括以下内容:
{% assets "scss_all" %}<link rel=stylesheet type=text/css href="{{ ASSET_URL }}">{% endassets %}SCSS文件也将在调试模式下进行编译。
pyScss只支持SCSS语法,但也有其他过滤器(
sass,
scss和
compass)使用原始的Ruby实现。



