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.

Parse error with CSS custom properties with default values including a nested calc

See original GitHub issue

The following CSS:

div {
    margin-right: calc(var(--b, calc(var(--c) * 1)));
}

Leads to the following parser error:

JisonParserError: Parse error on line 1: 
var(--b, calc(var(--c)*1))
-------------------------^
Expecting end of input, "ADD", "SUB", "MUL", "DIV", got unexpected "RPAREN"

Looking at the Stack trace, here’s the chain of the last few operations leading to the issue:

at Parser.parseError (/node_modules/postcss-calc/dist/parser.js:1164:15)
at Parser.parse (/node_modules/postcss-calc/dist/parser.js:1680:30)
at /node_modules/postcss-calc/dist/lib/transform.js:30:30

Removing the last * 1 part removes the parser error.

Issue Analytics

  • State:open
  • Created 4 years ago
  • Reactions:8
  • Comments:23 (2 by maintainers)

github_iconTop GitHub Comments

17reactions
eric1iucommented, May 10, 2019

As a workaround, disable postcss-calc in package.json to pass gatsby build in my case.

  "cssnano": {
    "preset": [
      "default",
      {
        "calc": false
      }
    ]
  }

Will enable again once this bug fixed. Thanks!

5reactions
HZoolycommented, Feb 5, 2020

Any example of this for removing postcss-calc from Gatsby build please? I can’t achieve this…

I tried to edit my postcss.config.js, unsuccessful.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Parse error with CSS custom properties with default values including ...
Parse error with CSS custom properties with default values including a nested calc.
Read more >
Post CSS parse error on calc() of CSS variables with several ...
I'm running a Nuxt.JS project with Post CSS and get the following error while generating the project's static ...
Read more >
Using CSS custom properties (variables) - MDN Web Docs
Custom properties are subject to the cascade and inherit their value from their parent. Basic usage. Declaring a custom property is done using...
Read more >
A Complete Guide to Custom Properties | CSS-Tricks
Above, --spacing is the custom property with 1.2rem as the value and ... syntax, how it interacts with the cascade, and its initial...
Read more >
CSS Custom Properties In The Cascade - Smashing Magazine
The nested p element has no color specified, so the results are determined by inheritance (the color of the direct parent) rather than...
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 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