Skip to content
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

[Bug]: & operator is not working in less module #4405

Open
gz65555 opened this issue Jan 21, 2025 · 4 comments
Open

[Bug]: & operator is not working in less module #4405

gz65555 opened this issue Jan 21, 2025 · 4 comments
Assignees

Comments

@gz65555
Copy link

gz65555 commented Jan 21, 2025

Version

System:
  OS: Linux 6.1 Debian GNU/Linux 11 (bullseye) 11 (bullseye)
  CPU: (32) x64 13th Gen Intel(R) Core(TM) i9-13900K
  Memory: 44.37 GB / 62.38 GB
  Container: Yes
  Shell: 5.8 - /usr/bin/zsh
Browsers:
  Chrome: 131.0.6778.204
npmPackages:
  @rsbuild/core: ^1.1.8 => 1.1.14 
  @rsbuild/plugin-less: ^1.1.0 => 1.1.0 
  @rsbuild/plugin-react: ^1.0.7 => 1.1.0

Details

This is the original code of less.

.test {
  background-color: rebeccapurple;
}
:global(.hello) {
  background-color: aqua;

  &-world {
    background-color: brown;
  }
}

When I used the & operator, the built output did not include the class modified by &. The output is:

.test-vRkBOC{background-color:#639}.hello{background-color:#0ff}

Reproduce link

https://codesandbox.io/p/github/gz65555/rsbuild-less-bug-feedback/main?import=true

Reproduce Steps

  1. Run pnpm i & pnpm build
  2. Check the output folder and open the css file

You can see there is no .hello-world class here

@gz65555
Copy link
Author

gz65555 commented Jan 22, 2025

I think it's a problem cause by lightingcss, which is used by rsbuild.

If I don't use the lightingcss-loader, the result is ok.

@chenjiahan
Copy link
Member

@GiveMe-A-Name Can you take a look at this lightningcss related issue?

@GiveMe-A-Name
Copy link
Member

GiveMe-A-Name commented Jan 24, 2025

The css is not validate css by transform by less-loader, So lightningcss can't transform the css code correctly, lightningcss playground

.test {
  background-color: rebeccapurple;
}
:global(.hello) {
  background-color: aqua;

  &-world {
    background-color: brown;
  }
}

After less-loader, the css will become:

.test {
background-color: rebeccapurple;
}
:global(.hello) {
background-color: aqua;
}
/* invalidate */
:global(.hello)-world {
background-color: brown;
}

@GiveMe-A-Name
Copy link
Member

I think is not a bug in lightningcss, but recover error css can be lightningcss feature.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants