2👍
Try using django_compressor with COMPRESS_PRECOMPILERS settings.
COMPRESS_PRECOMPILERS = (
('text/less', 'lessc {infile} {outfile}'),
)
Template:
{% compress css %}
<link type="text/less" rel="stylesheet" href="/static/css/styles.less" charset="utf-8">
<style type="text/less">
@color: #4D926F;
#header {
color: @color;
}
</style>
{% endcompress %}
1👍
The django-grunt project looks promising. I haven’t tried it myself yet, though – at first glance it doesn’t seem to support the nice grunt development watch-server workflow for quicker development that you get in a Yeoman webapp (at least it’s not documented on their README).
For my current open source project, I created a kind-of hacky solution that I’m still iterating on, but it does work:
- I keep my static files and the base template as a normal Yeoman-scaffolded Grunt project in its own GitHub repo, using buildcontrol to export the built files in a separate branch for Heroku deployment
- the Django app is a normally laid out Django app, with some script magic to link up the development or production versions of the frontend code into my static folders (I can keep grunt server running to quickly iterate on the frontend code)
- to deploy to Heroku, I use a minimally-modified python buildpack that fetches the production branch of the frontend repo and links it up using the aforementioned script (I tried building it using grunt on Heroku, but it took ages to fetch all the npm dependencies every time, so I found buildcontrol to be much more efficient)
Update: I’m since iterating on making everything work in a single repo in this project.
Source:stackexchange.com