我将 django-1.3 与 django-staticfiles-1.2.1 和 django-pipeline-1.2.6 一起使用 此设置应根据文档工作。
在我的项目的根目录中,我有一个目录 staticfiles
,其中包含一个包含我的 sass 文件的目录 sass
。
我希望看到 django-pipeline 编译我的 sass 文件并将它们放入/static/css/master.css
这是我的 settings.py 文件的摘录
MEDIA_ROOT = '/home/jonasg/dev/projectX/media/'
STATIC_ROOT = 'static/'
STATIC_URL = '/static/'
PIPELINE=True
PIPELINE_AUTO=True
STATICFILES_STORAGE = 'pipeline.storage.PipelineStorage'
STATICFILES_DIRS = (
'staticfiles',
)
PIPELINE_COMPILERS = (
'pipeline.compilers.sass.SASSCompiler',
)
PIPELINE_CSS_COMPRESSOR = 'pipeline.compressors.cssmin.CssminCompressor'
PIPLINE_CSS = {
'base': {
'source_filenames': (
'sass/*.sass'
),
'output_filename': 'css/master.css'
}
}
PIPELINE_COMPILERS = (
'pipeline.compilers.sass.SASSCompiler',
)
PIPELINE_SASS_BINARY='/usr/bin/sass'
STATICFILES_FINDERS = (
'staticfiles.finders.FileSystemFinder',
'staticfiles.finders.AppDirectoriesFinder',
'staticfiles.finders.DefaultStorageFinder'
)
当我运行 ./manage.py collectstatic 时,/staticfiles 中的所有文件都被复制到/static 但没有编译或缩小。 我还注意到此命令从/media 获取所有内容并将它们放在/static 中,这不是我期望的行为。
此外,您可能已经在上面注意到,我正在使用 django-staticfiles,如果您仍在使用 django-1.3,django-pipeline 会推荐它。如果此应用已迁移到 django-1.3,我不明白为什么还要坚持使用 django-staticfiles?
最佳答案
SASS 编译器期望您的 sass 文件具有扩展名 .scss
。
看起来 SASS 添加了另一个扩展/语法,它将在下一个版本的管道中修复。
不要忘记像这样更改静态文件存储:
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
关于python - django-pipeline 不编译 sass 文件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10672758/