data: URIs containing spaces break some CSS minifiers
See original GitHub issueAs best I understand, this is not strictly a bug in Bootstrap, but I think you can work around it and make deployment easier for people without hurting anything.
The navbar-toggler-icon
background-image
is a url()
with a data:
URI that contains space characters. At least rCSSmin, which is the default minifier for django-compressor, assumes that url()
can’t contain spaces, according to ndparker/rcssmin#8.
If you wrap variables such as $navbar-dark-toggler-icon-bg
in an additional str-replace(..., " ", "%20")
then these minifiers work fine.
Since these variables are only used once each this isn’t a big change to the generated CSS but makes Bootstrap easier to deploy, so I hope you’ll consider making this change.
Issue Analytics
- State:
- Created 6 years ago
- Comments:5 (1 by maintainers)
Top Results From Across the Web
How to Minify CSS and JavaScript in WordPress - WP Rocket
Let's go over the main techniques to minify JS and CSS. Online tools. Toptal (previously known as Javascript minifier) – a user-friendly tool...
Read more >When a Line Doesn't Break - CSS-Tricks
We expect a line to break when the text on that line reaches the parent box ... Some of these values are whitespaces,...
Read more >How to deal with relative image URL changing when CSS is ...
This minification process may break some of the relative URLs because it effectively flattens the folder structure. As a developer, how do you...
Read more >HTML minifier
Collapse inline tag whitespace Don't leave any spaces between display:inline; elements when collapsing. Must be used in conjunction with collapseWhitespace= ...
Read more >Minify - JavaScript and CSS minifier
This minifier removes whitespace, strips comments, combines files, and optimizes/shortens a few common programming patterns. And it comes with a huge test suite ......
Read more >
Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free
Top Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Some additional ideas from webpack with roots/sage:
A ‘Clean’ Workaround
TL;DR
1. In Your
assets/styles/main.scss
insert at the top of the file (yes, before@import "common/variables";
, we need the functions forstr-replace()
):2. In Your
styles/common/_variables.scss
insert:Detail
The Problem aren’t the spaces. The brackets from the
stroke='#{$navbar-dark-color}'
causes the problem. So if westr-replace()
the(
with%28
and the)
with%29
you can runyarn run build:production
without removing your scss.Reference: Bootstrap 4 CSS error when minifying with webpack, causes loss of SCSS running build:production
I know I know… who uses stylelint… but my OCD loves it. If you want this little patch to work and still validate with your stylelint, this is what you need to be putting in your /common/_variables.scss file:
The problem was that the str-replace inline in the data:image blob was causing stylelint to fail. Creating a new variable outside of that string and passing it into the blob worked like a charm.
Along with the rest of what @sandrowuermli recommends above.