3

I'm using django-pipeline to minify my CSS. Everything minifies correctly until I use PipelineCachedStorage so I can get the versioned, cache-busting filenames. I get the following error:

ValueError: The file 'img/glyphicons-halflings.png' could not be found with <pipeline.storage.PipelineCachedStorage object at 0x19069d0>

I've grepped all the files in my project and have found that this PNG is in bootstrap.css, but I am not including that file to be minified. Here's my django-pipeline specific settings:

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'

Thanks in advance!

EDIT:

new settings for pipeline:

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'

2 Answers 2

6

The error isn't entirely related to Pipeline but rather what Django's CachedStaticFilesStorage that PipelineCachedStorage extends. The cached storage will look for file references in your css files and replace url('asset-link') and @import 'resource-link' with the appropriate link to the version with the md5 hash appended to it.

This will turn url('img/glyphicons-halflings.png') into url('img/glyphicons-halflings.<hash>.png'). So if you have asset references in your css files but don't have the underlying assets, the post_process() of CachedStaticFilesStorage is going to throw that error.

You can read more here. I'd recommend to compile the less version of bootstrap with django pipeline and remove the less components that you don't need, such as the icons if you don't want to include the bootstrap icons. Or you can include the appropriate assets.

Sign up to request clarification or add additional context in comments.

8 Comments

What do you mean by the "less version of bootstrap"? Do you mean bootstrap.min.css instead of bootstrap.css?
github.com/twbs/bootstrap/tree/master/less You can use django-pipeline to compile less into css as well. Alternatively you can just go through bootstrap.css and removing the offending lines.
Ah, right, got it. I'll give this a try when I'm back behind my computer and let you know how it goes. Thanks!!
I've made some progress (installed ruby, lessc, etc), but I'm running into another error: IOError: [Errno 2] No such file or directory: u'/home/redacted/ts/redacted/redacted/assets/bootstrap-less/bootstrap.css'. Why would it be looking for that file? It doesn't exist in the bootstrap.less package and it isn't specified anywhere. I posted my additions to my settings file in my original post.
Is this error during collectstatic? Or is this in the development server?
|
2

I've found the django-pipeline-forgiving package resolves this issue with the stock Django CachedStaticFilesStorage / PipelineCachedStorage very nicely

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.