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)
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.