Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Is there an alternative to the Rails assets pipeline for Django?

Using the Rails assets pipeline and a plugin for require.js, I can use CoffeeScript, SASS, files organized however I like and get it all compiled to a single JavaScript and single CSS file for production. Is there a matching setup for use with Django? It needs to support the above, CofeeeScript, SASS, Require.JS with a development mode where files are served individually as well as a production mode where everything gets compiled into single files.

like image 354
SoftMemes Avatar asked Mar 10 '12 13:03

SoftMemes


1 Answers

I’m using Django Compressor and I’m pretty happy with it. It supports pre-processors so Coffeescript, Sass and so on are supported. Check out the documentation.

EDIT: Here is my settings for SASS and Coffeescript, in settings.py:

STATICFILES_FINDERS = (
  'django.contrib.staticfiles.finders.FileSystemFinder',
  'django.contrib.staticfiles.finders.AppDirectoriesFinder',
  'compressor.finders.CompressorFinder',
)

COMPRESS_PRECOMPILERS = (
  ('text/coffeescript', 'coffee --compile --stdio'),
  ('text/x-sass', 'sass {infile} {outfile}'),
  ('text/x-scss', 'sass --scss {infile} {outfile}'),
)
like image 62
Jérôme Mahuet Avatar answered Oct 20 '22 02:10

Jérôme Mahuet