Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Compress css inline data:svg broken data. #743

Open
suxilog opened this issue Jan 21, 2021 · 0 comments
Open

Compress css inline data:svg broken data. #743

suxilog opened this issue Jan 21, 2021 · 0 comments

Comments

@suxilog
Copy link

suxilog commented Jan 21, 2021

I compress bootstrap.css,
Below is original css:

.custom-checkbox .custom-control-input:checked ~ .custom-control-label::after {
  background-image: url("data:image/svg+xml,%3csvg xmlns='http://www.w3.org/2000/svg' viewBox='0 0 8 8'%3e%3cpath fill='%23fff' d='M6.564.75l-3.59 3.612-1.538-1.55L0 4.26 2.974 7.25 8 2.193z'/%3e%3c/svg%3e");
}

this is compressed css:

.custom-control-label::after{
	background-image:url("data:image/svg+xml,%3csvgxmlns='http://www.w3.org/2000/svg'viewBox='0044'%3e%3cpathstroke='%23fff'd='M02h4'/%3e%3c/svg%3e")}

All blank space beed removed.

I have set variant to datauri

Below is my code, anyone could help me?

PIPELINE = {
    # 'SHOW_ERRORS_INLINE': True,
    # 'CSS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
    # 'JS_COMPRESSOR': 'pipeline.compressors.yuglify.YuglifyCompressor',
    'STYLESHEETS': {
        'bs4_css': {
            'source_filenames': (
                'css/bootstrap.min.css',
                'css/mdb.css',
            ),
            'output_filename': 'css/bs4.css',
            'variant': 'datauri',
            
        },
        'addon_css': {
            'source_filenames': {
                'wagtailfontawesome/css/fontawesome.css',
                'css/addons/flag.min.css',
                'css/addons/flickity.min.css',
                'css/addons//PhotoSwipe/photoswipe.css',
                'css/addons/PhotoSwipe/default-skin/default-skin.css',
            },
            'output_filename': 'css/addon.css',
            'variant': 'datauri',
        }
    },
    'YUGLIFY_BINARY': '/usr/bin/env yuglify',
zarino added a commit to mysociety/caps that referenced this issue Dec 2, 2022
By default, Django Pipeline removes spaces from Data URIs used in
stylesheets. This causes a problem when you use SVG markup in your
Data URIs, as Bootstrap does for its mobile navbar toggle icon.

The Django Pipeline docs suggest that `variant: datauri` fixes this:

https://django-pipeline.readthedocs.io/en/latest/configuration.html?highlight=variant#variant

Thanks also to @suxilog for identifying and suggesting this fix:

jazzband/django-pipeline#743

Fixes #462.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant