-
Notifications
You must be signed in to change notification settings - Fork 3.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
CSS variables in LESS variables breaks sourcemaps #3300
Comments
Interesting... |
lol 😄 Took me forever to figure out what was going on -- for the longest time I thought it was a webpack/less-loader issue |
I believe I have a similar issue, that may be caused by the same thing. I'm on less 3.8.0, as published 10 days ago on NPM ( My sourcemaps are not broken, but my app style is. We defined rgba values in variables, and they come out broken from the compilation process. Our original code made use of transparency in hex form, stored in CSS variables ( We tried changing it to an rgba function, but then it is converted into a hex without transparency. I too thought it was related to the webpack bundling process one way or another, until I tried compiling the files directly using So: I don't know what else is broken in the variables system, but for us, it means that we cannot get transparency go through. We'll revert to the previous version of less until then. |
@pascallaprade-beslogic No, your issue is not related. Your issue is an older one where the RGBA form was not supported at all, and that's been added only recently. See this PR - #3291 |
@eamodio Can you test this branch and verify that source maps are generated as expected? https://github.com/matthew-dean/less.js/tree/bugfix-3300. If so, I'll do a proper release. The sourcemaps test coverage was pretty minimal and I had to do lots of rewriting of tests, so I want to verify it's working properly. |
@pascallaprade-beslogic Can you test against that branch as well as it should have your fix? |
Thank you very much! I tested the branch you linked above with our two cases, the rgba hex and the rgba function: the hex came out without the duplicated alpha value at the end, and the rgba function was left as is in the output, instead of being transformed into a hex without the alpha value. Thanks again! |
@pascallaprade-beslogic So, not to contradict you, but I'm re-testing, and I the |
No, you are right! The rgba function I showed in my first message in this thread was wrong. I rarely use rgba functions, so I did not use an alpha value in the correct range. (As I said in my first message, we only use hex values in our app, so the rgba attempt was just me trying to see if it affected rgba as well, and going too fast to realize I was doing it wrong.) However, I realized it when I did the test today, and wrote the proper rgba function. So indeed, only the hex was broken, the rgba worked as expected. Here's my latest test that shows the three attempts I made, hex, wrong rgba and correct rgba: .test {
--hex: #00112233;
--rgba-wrong: rgba(1, 2, 3, 4);
--rgba-right: rgba(1, 2, 3, 0.5);
} Output with .test {
--hex: #00112233 33;
--rgba-wrong: #010203;
--rgba-right: rgba(1, 2, 3, 0.5);
} Output with .test {
--hex: #00112233;
--rgba-wrong: #010203;
--rgba-right: rgba(1, 2, 3, 0.5);
} So, again, sorry for the false alarm about the rgba function being affected as well, I do realize it was my mistake there. And thank you for your time about validating that the hex is indeed fixed in that unreleased branch! |
@matthew-dean sorry for the delay in getting back to you, but it looks resolved. No more errors and the source maps (as far as a quick test) look good. Thank you!! |
@eamodio Good to hear! You're welcome! |
Might be related to less/less.js#3300
If you compile this with sourcemaps on, it fails with
SyntaxError: Cannot read property 'substring' of undefined
on theborder-top
. If you don't use a CSS variable for@color
it will work fine, and also until a use ofcalc()
everything will also work fine. But any rules after the use ofcalc
will fail if the rule is a mix of css and a variable.The text was updated successfully, but these errors were encountered: