2012-03-10 57 views
6

使用Rails资产管道和一个用于require.js的插件,我可以使用CoffeeScript,SASS,但我喜欢的文件,并将其全部编译为单个JavaScript和单个CSS文件进行生产。是否有与Django一起使用的匹配设置?它需要支持上述的CofeeeScript,SASS,Require.JS以及单独提供文件的开发模式以及将所有内容编译为单个文件的生产模式。Django有没有替代Rails资产管道的方法?

回答

7

我正在使用Django Compressor,我对此很满意。它支持预处理器,因此支持Coffeescript,Sass等。查看文档。

编辑: 这里是我的SASS和CoffeeScript的设置,在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}'), 
) 
+2

关于获得requirejs优化器有什么..? – SoftMemes 2012-03-10 19:34:21

+0

我为labjs创建了一个与django压缩器兼容的模板标签:https://github.com/ashwoods/django-labjs – ashwoods 2012-03-11 10:31:41

相关问题