Using sass with Flask and jinja2

前端 未结 4 1667
我在风中等你
我在风中等你 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:12

    Simple one line solution using libsass, after you import sass simply use the compile function with the dirname keyword argument, like this:

    sass.compile(dirname=('path/to/sass', 'path/to/css'))
    

    You also have the option to set the output style, for example:

    sass.compile(dirname=('path/to/sass', 'path/to/css'), output_style='compressed')
    

    More info: https://sass.github.io/libsass-python

提交回复
热议问题