1

In my small flask app I have static/styles/

├── base
│   └── _variables.scss
├── components
│   └── _header.scss
├── site.min.css
├── site.scss
└── vendor
    ├── foundation

In my base template I am using

{% assets filters='compass,scss,cssmin', output='styles/site.min.css', 'styles/site.scss'%}
        <link rel="stylesheet" type="text/css" href="{{ ASSET_URL }}">
{% endassets %}

to import the stylesheet. My problem is that when I make a style change in _header.scss or _variables.scss my stylesheet doesn't update. Only when I update site.scss.

Here's my relevant python code:

import sys
from flask import Flask, render_template
from flask.ext.assets import Environment, Bundle # FED Assets
# Need Sass `gem install sass`

app = Flask(__name__)
assets = Environment(app) # FED Assets
app.config.from_object(__name__)

@app.route("/")
def index():
    return render_template('index.html')

if __name__ == "__main__":
    app.run(host='0.0.0.0', debug=True)
anthony-dandrea
  • 2,583
  • 7
  • 26
  • 46

1 Answers1

1

Simply add a depends node to your Bundle configuration:

{% assets filters='compass,scss,cssmin', depends='**/*.scss' output='styles/site.min.css', 'styles/site.scss'%}
        <link rel="stylesheet" type="text/css" href="{{ ASSET_URL }}">
{% endassets %}

Note that this will disable caching for the bundle, but if you build your assets on deployment and only deploy the compiled code, you should be fine.

Sean Vieira
  • 155,703
  • 32
  • 311
  • 293
  • Thank you. I was doing `depends='*.scss'` to no avail. Looks like with my specific directory structure `depends='styles/**/*.scss',` did the trick. – anthony-dandrea Mar 17 '15 at 18:20