I'm currently trying to set up a Flask web app, and trying to use Flask-Assets
to compile my less files into minified css.
Here is my assets.py file that creates the bundle.
from flask_assets import Bundle
common_css = Bundle(
'vendor/less/theme.less',
filters='less',
output='static/css/common.css',
)
The error that I am getting is:
OSError: [Errno 2] No such file or directory
In the webassets
documentation for the less filter, it says that:
This depends on the NodeJS implementation of less, installable via npm. To use the old Ruby-based version (implemented in the 1.x Ruby gem), see Less.
...
LESS_BIN (binary)
Path to the less executable used to compile source files. By default, the filter will attempt to run lessc via the system path.
I installed less
using $ npm install less
, but for some reason it looks like webassets
can't use it.
When I try to use different filters, then webassets
can successfully create the bundle.
Thanks!
npm install
installs packages in current directory by default (you should be able to find node_modules
directory there). You have two choices:
Install lessc
globally:
$ npm install -g less
This way webassets will be able to find it itself.
Provide a full path to lessc
executable:
assets = Environment(app)
assets.config['less_bin'] = '/path/to/lessc'
The path should be <some_directory>/node_modules/.bin/lessc
.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With