less.js icon indicating copy to clipboard operation
less.js copied to clipboard

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

Open weareoutman opened this issue 4 years ago • 12 comments

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.

weareoutman avatar Oct 16 '20 09:10 weareoutman

Same issue in my project.

IMO the darken() should not been called since its already overridden.

kpaxqin avatar Nov 16 '20 03:11 kpaxqin

+1

srfaytkn avatar Nov 27 '20 13:11 srfaytkn

+1

FengShangWuQi avatar Mar 02 '21 10:03 FengShangWuQi

Same issue, any news ? I also posted a question on stack overflow but no solution nor workaround yet.

lucataglia avatar Mar 07 '21 00:03 lucataglia

same issue

da-anda avatar Jul 21 '21 12:07 da-anda

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

iChenLei avatar Jul 21 '21 12:07 iChenLei

same issue

snoweastcn avatar Sep 29 '21 02:09 snoweastcn

same issue

tusharrathi1993 avatar Jan 28 '22 07:01 tusharrathi1993

I'm having a similar issue: https://github.com/less/less.js/issues/3611#issuecomment-1172325438

crossan007 avatar Jul 01 '22 13:07 crossan007

Looks like https://github.com/less/less.js/pull/3721

crossan007 avatar Jul 01 '22 13:07 crossan007