thr*_*eez 3 django django-pipeline yuglify
我正在使用django-pipeline来缩小我的CSS.一切都正确缩小,直到我使用PipelineCachedStorage,这样我就可以得到版本化的缓存破坏文件名.我收到以下错误:
ValueError: The file 'img/glyphicons-halflings.png' could not be found with <pipeline.storage.PipelineCachedStorage object at 0x19069d0>
Run Code Online (Sandbox Code Playgroud)
我已经在我的项目中找到了所有文件并且发现这个PNG在bootstrap.css中,但是我没有将该文件包括在内.这是我的django-pipeline特定设置:
PIPELINE_CSS = {
'ab': {
'source_filenames': (
'main.css',
'segment-animation.css',
),
'output_filename' : 'ab.css',
}
}
PIPELINE_YUGLIFY_BINARY = '/home/redacted/ts/redacted/node_modules/yuglify/bin/yuglify'
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
Run Code Online (Sandbox Code Playgroud)
提前致谢!
编辑:
管道的新设置:
PIPELINE_COMPILERS = (
'pipeline.compilers.less.LessCompiler',
)
PIPELINE_CSS = {
'ab': {
'source_filenames': (
'bootstrap-less/bootstrap.less',
'main.css',
'segment-animation.css',
),
'output_filename' : 'ab.css',
}
}
PIPELINE_YUGLIFY_BINARY = '/home/redacted/ts/redacted/node_modules/yuglify/bin/yuglify'
STATICFILES_STORAGE = 'pipeline.storage.PipelineCachedStorage'
Run Code Online (Sandbox Code Playgroud)
该错误与Pipeline并不完全相关,而是扩展了Django的CachedStaticFilesStorage内容PipelineCachedStorage.缓存存储将查找文件引用您的css文件和替换url('asset-link'),并@import 'resource-link'与相应的链接的版本与附加给它的MD5哈希值.
这将url('img/glyphicons-halflings.png')变成url('img/glyphicons-halflings.<hash>.png').所以,如果你在你的CSS文件引用的资产,但不具备相关资产,该post_process()的CachedStaticFilesStorage是要抛出错误.
你可以在这里阅读更多.我建议使用django管道编译较少版本的bootstrap,并删除不需要的较少组件,例如,如果您不想包含引导程序图标,则删除图标.或者您可以包含适当的资产.
| 归档时间: |
|
| 查看次数: |
1985 次 |
| 最近记录: |