Jon*_*gat 5 python django sass
我正在使用 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'
)
Run Code Online (Sandbox Code Playgroud)
当我运行 ./manage.pycollectstatic 时,/staticfiles 中的所有文件都会复制到/static 中,但不会编译或缩小任何内容。我还注意到这个命令从 /media 获取所有内容并将它们放在 /static 中,这不是我所期望的行为。
另外,您可能已经注意到上面我使用的是 django-staticfiles,如果您仍在使用 django-1.3,则 django-pipeline 推荐使用它。我不明白为什么我应该坚持使用 django-staticfiles 如果这个应用程序已迁移到 django-1.3 ?
SASS 编译器期望您的 sass 文件具有扩展名.scss
. 看起来 SASS 添加了另一个扩展/语法,它将在下一版本的管道中修复。
不要忘记像这样更改静态文件存储:
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
Run Code Online (Sandbox Code Playgroud)
归档时间: |
|
查看次数: |
3747 次 |
最近记录: |