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.

PostCSS can't parse CSS variable values

See original GitHub issue

It appears PostCSS has difficulty parsing CSS variables according to CSS’s syntax, examples include:

examples {
  --bracket-block: {1, 2, 3};
  --JSON: [1, "2", {"three": 3}, [4]];
  --javascript: function(rule) { console.log(rule) };
}

You can find more known-valid examples of CSS variables in my css-tests repository, or in the Web Platform Tests repository, and you can read about the syntax for CSS variable values in the CSS Variables spec

The allowed syntax for custom properties is extremely permissive. The <declaration-value> production matches any sequence of one or more tokens, so long as the sequence does not contain <bad-string-token>, <bad-url-token>, unmatched <)-token>, <]-token>, or <}-token>, or top-level <semicolon-token> tokens or <delim-token> tokens with a value of “!”.

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Reactions:1
  • Comments:14 (8 by maintainers)

github_iconTop GitHub Comments

2reactions
aicommented, May 4, 2019

The fix was released in 7.0.15.

2reactions
stas-dolgachovcommented, Apr 25, 2019

@ai @tomhodgins hey! I have started to work on that. I am new to PostCSS source code, so it could take a while. I will give an update in a week or so.

Read more comments on GitHub >

github_iconTop Results From Across the Web

css variables are not properly processed in scss files [duplicate]
I have a problem with css variables used in scss files. When it's used as a pure value works fine, for example: iside...
Read more >
Want CSS variables in media query declarations? Try this!
These declarations are processed while your CSS is being parsed, so it won't know to look to the :root and pull in the...
Read more >
var() - CSS: Cascading Style Sheets - MDN Web Docs - Mozilla
The var() CSS function can be used to insert the value of a custom property (sometimes called a "CSS variable") instead of any...
Read more >
How to create a file by file custom SCSS build including ...
dist/development/css-no-vars/theme-dark/button/Base.css: In this scenario we just get one file which contains the values of the scss variables.
Read more >
postcss-css-variables - npm
PostCSS plugin to transform CSS Custom Properties(CSS variables) syntax into a static representation. Latest version: 0.18.0, ...
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