Hi, I'm using a loader which would set the compress option in production mode. But in the production mode, less will do this:
https://github.com/less/less.js/blob/b8140d4baad18ba732e2b322d8891a9b0ff065d5/lib/less/tree/dimension.js#L43-L54
if (context && context.compress) {
// Zero values doesn't need a unit
if (value === 0 && this.unit.isLength()) { // <<<<<<<<<<<------ see here
output.add(strValue);
return;
}
// Float values doesn't need a leading zero
if (value > 0 && value < 1) {
strValue = (strValue).substr(1);
}
}
So, if I use something like:
calc(0px + 1rem + 2rem)
it will output:
calc(0 + 1rem + 2rem)
which will make the css broken in production mode.
Yea, why I don't just use calc(1rem + 2rem)? That's because this is just an example, actually I use calc(@offset - env(safe-area-inset-bottom)) in my less file(@offset will be 0 sometimes).
So, is this a bug? IMO, we could don't remove the unit(i.e. 'px') when in the calc expression but I'm not familiar with the less codebase.
Hi, I'm using a loader which would set the
compressoption in production mode. But in the production mode, less will do this:So, if I use something like:
calc(0px + 1rem + 2rem)it will output:
calc(0 + 1rem + 2rem)which will make the css broken in production mode.
Yea, why I don't just use
calc(1rem + 2rem)? That's because this is just an example, actually I usecalc(@offset - env(safe-area-inset-bottom))in my less file(@offsetwill be0sometimes).So, is this a bug? IMO, we could don't remove the unit(i.e. 'px') when in the
calcexpression but I'm not familiar with the less codebase.