Using sass with Flask and jinja2

前端 未结 4 1668
我在风中等你
我在风中等你 2021-01-30 08:51

I would like to include a sass compiler in my Flask application. Is there a generally accepted way of doing this?

4条回答
  •  無奈伤痛
    2021-01-30 09:22

    Currently, exist a better approach for this issue, the extion Flask-Scss.

    You just have to install it: pip install Flask-Scss

    And instanciate a Scss object after configuring the application (probably in your manage.py file):

    from flask import Flask
    from flask.ext.scss import Scss
    
    app = Flask(__name__)
    Scss(app)
    

    By default, the extension will look for your .scss files in {app.root_dir}/assets/scss or {app.root_dir}/assets and will put the generate .css files in {default_static_dir}/css or {default_static_dir}.

提交回复
热议问题