question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

CSS custom properties are not polyfilled

See original GitHub issue

Is this a bug report?

Yes

I have CSS variables (custom properties) in my CSS, which are not supported by IE. The CRA docs state “Support for new CSS features like the all property, break properties, custom properties, and media query ranges are automatically polyfilled to add support for older browsers.” However, they are not polyfilled when they are imported from another file.

Steps to reproduce

// A.css
:root {
  --test: #fff;
}
// B.css
@import 'A.css'
body {
  color: var(--test)
}

Expected Behavior

The built CSS file should have the CSS variables processed out and replace the var(–) calls with the proper values

Actual Behavior

The autoprefixer works as expected, adding vendor prefixes and such, and changing the browserslist settings do alter the outputted CSS in some way. However, no browserslist setting is making the custom properties be post-processed, and as such the CSS will not work on IE. It seems like the variable replacement is happening before the concatenation from imports, and so it doesn’t find the property definition from other files.

Note that I also deleted node_modules and package-lock and the issue persists.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Comments:25 (4 by maintainers)

github_iconTop GitHub Comments

6reactions
vivekweb2013commented, Sep 22, 2019

This is still not resolved? CSS custom properties are such a cool feature which I’m still not using due to its incompatibility with IE 11. I don’t want to add SASS/LESS into the project, rather use this awesome CSS feature that is now part of CSS specification. Waiting for this issue to get resolved…

6reactions
chcecommented, Jul 17, 2019

Also seeing this issue.

Read more comments on GitHub >

github_iconTop Results From Across the Web

CSS custom properties polyfill for ie11 - Stack Overflow
I was thinking on load, check if browser supports custom properties and if not do some kind of find and replace on the...
Read more >
Custom properties (--*): CSS variables - MDN Web Docs
Custom properties are scoped to the element(s) they are declared on, and participate in the cascade: the value of such a custom property...
Read more >
A Complete Guide to Custom Properties | CSS-Tricks
Everything important and useful to know about CSS Custom Properties. Like that they are often referred to as "CSS Variables" but that's not...
Read more >
css-vars-ponyfill - GitHub Pages
css-vars-ponyfill - Client-side support for CSS custom properties (aka "CSS variables") in legacy ... This library is offered as a ponyfill, not a...
Read more >
CSS Variables (Custom Properties) | Can I use... Support ...
CSS Variables (Custom Properties). - CR. Permits the declaration and usage of cascading variables in stylesheets. Usage % of. all users, all tracked ......
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found