[Django]-How do you deploy a project using Less CSS to Heroku?

2👍

The problem is that less.js loads the .less stylesheets through XHR, which doesn’t work unless you set the appropriate Access-Control-Allow-Origin header, which S3 doesn’t permit (https://forums.aws.amazon.com/thread.jspa?threadID=34281).

As a workaround some people have suggested setting up an HTTP Proxy, which adds the necessary header. (http://motoole.com/2011/10/19/hosting-font-face-fonts-on-s3.html) and (http://zefer.posterous.com/pure-html-ajax-solutions-to-upload-files-to-s)

Otherwise, you’re going to have to compile the .less files to CSS, as less.js isn’t going to work.

Of course, another alternative (which I use), is to simply deploy the static files to an Apache server, and not host them in S3.

1👍

Take a look at https://github.com/nigma/heroku-django-cookbook

It makes use of the post_compile hook provided by heroku-buildpack-python to install nodejs and lessc.

Leave a comment