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.

Lazy variables of css custom properties with less functions (even if it's overwritten) will break building

See original GitHub issue

To simplify the issue, let’s assume a third-party-library which contains:

// `library/style.less`
@base-color: green;
@dark-color: darken(@base-color, 50%);

.some-class {
  color: @base-color;
  backgroundColor: @dark-color;
}

And my app would like to override the colors to css custom properties:

// app.less
import "~library/style.less";

@base-color: var(--primary-color);
@dark-color: var(--bg-color);

:root {
  --primary-color: #fff;
  --bg-color: #000;
}

html[data-theme="dark"] {
  --primary-color: #000;
  --bg-color: #fff;
}

In which I want to override both the @base-color and @dark-color less variables. However, the less will fail with LessError: error evaluating function `darken`: Argument cannot be evaluated to a color, even if the @dark-color in library is actually overridden in my app, and no darken() function should be called.

Issue Analytics

  • State:open
  • Created 3 years ago
  • Reactions:4
  • Comments:10 (1 by maintainers)

github_iconTop GitHub Comments

6reactions
iChenLeicommented, Jul 21, 2021

Sorry for slow response, I will investgate this issue. 🕵️

0reactions
crossan007commented, Jul 1, 2022
Read more comments on GitHub >

github_iconTop Results From Across the Web

Breaking CSS Custom Properties out of :root Might Be a Good ...
The main reason that :root is suggested is because CSS isn't only used to style HTML documents. It is also used for XML...
Read more >
Features In-Depth | Less.js
Less extends CSS with dynamic behavior such as variables, mixins, operations and functions. Less runs on both the server-side (with Node.js and Rhino)...
Read more >
Using CSS custom properties (variables) - MDN Web Docs
Custom property fallback values​​ Using the var() function, you can define multiple fallback values when the given variable is not yet defined; ...
Read more >
A Strategy Guide To CSS Custom Properties
CSS Custom Properties (sometimes known as 'CSS variables') are ... or their scope can be limited to specific functions or blocks of code....
Read more >
Safari Technology Preview Release Notes - Apple Developer
toMatrix() to throw an exception if its length is not compatible with a px unit ... Fixed CSS.supports returning false for custom properties...
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