I have simply tried setting up flask-assets (based on webassets), however just can't get it to work.
I have the standard setup;
- python virtualenv
- pip to install the bare essentials (flask, flask-assets)
- sass ruby gem (for trying sass / scss)
- less via npm (for trying lesscss)
- jsmin via pip (for trying jsmin)
Config:
- I have created a working homepage in Flask
static
folder created (for css / js assets)- The css / js files are confirmed working (css background, js slider, etc)
- Basically my development non-flask-assets site is working perfectly
I have followed the easy official guide here: flask-assets usage. I fully understand how to work with it (as per that page). I have even exact copy-pasted the code, & still can't get it working.
Some code I've tried (for lesscss): (of course I have working css in main.less)
from flask.ext.assets import Environment, Bundle
assets = Environment(app)
assets.debug = True
lesscss = Bundle('main.less', output='main.css', filters='less')
assets.register('less', lesscss)
Then in my template:
{% assets "less" %}
<link href="{{ ASSET_URL }}" rel="stylesheet">
{% endassets %}
However flask-assets just won't work. I've tried the same with sass, scss, & also jsmin (exact code copy-paste from the usage guide) - it still won't work.
- I notice that the
.webassets-cache
folder is created, but is (always) empty...
Also; relevant error?; I expect it to create the main.css, but as it doesn't, I get an error in the browser (using app.debug = True
& flask's built-in dev server):
webassets.exceptions.BuildError
BuildError: Nothing to build for <Bundle output=css/main.css, filters=[<webassets.filter.less.Less object at 0x7f4958dc6710>], contents=('css/main.less',)>, is empty
So; If I manually create an empty main.css, it loads the page (no error), however the main.css file is not filled with css so flask-assets / webassets in still not working.
I've also tried passing the assets object to the template in various ways just in case it's needed (although no documentation states this) - that didn't work.
It's been driving me crazy. Any pointers would be appreciated.
Thank you