我已经配置django-pipeline
如下:
PIPELINE = {
'PIPELINE_ENABLED': True,
'COMPILERS': (
'pipeline.compilers.sass.SASSCompiler',
),
'STYLESHEETS': {
'common': {
'source_filenames': (
'sass/common/styles.scss',
),
'output_filename': 'css/common/styles.css',
}
}
}
我collectstatic
在调试模式下运行并启动了服务器,以查看一切是否设置正确。我可以访问我所有的图像和脚本,但不能访问已编译的 CSS 文件。我的静态设置:
STATIC_ROOT = os.environ.get('DJANGO_STATIC_ROOT', os.path.join(BASE_DIR, '_static'))
STATIC_URL = '/static/'
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'pipeline.finders.PipelineFinder',
)
更多观察:
- 我添加了一个断点
django.views.static.serve
,我注意到它会触发http://127.0.0.1:8000/static/sass/,但不会触发http://127.0.0.1:8000/static/css/或http:// 127.0.0.1:8000/static/css/common/styles.css。但是,编译后的 CSS 文件存在于_static/css/common/
(asstyles.css
和styles.cba140b2c4b2.css
) 中。 - 如果我将 的内容复制
_static/css/
到原始应用程序的static
文件夹中,则 CSS 会正常呈现。 - 另一个可能的症状是我的模板没有输出版本化的静态文件路径。
我怎样才能staticfiles
找到编译好的 CSS 文件?