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]: Rspack ignores layers specified on imports in the main css file #7452

Closed
dnwhte opened this issue Aug 4, 2024 · 4 comments · Fixed by #7583
Closed

[Bug]: Rspack ignores layers specified on imports in the main css file #7452

dnwhte opened this issue Aug 4, 2024 · 4 comments · Fixed by #7583
Labels
bug Something isn't working stale

Comments

@dnwhte
Copy link

dnwhte commented Aug 4, 2024

Version

System:
    OS: Windows 10 10.0.19045
    CPU: (8) x64 Intel(R) Core(TM) i7-8650U CPU @ 1.90GHz
    Memory: 5.32 GB / 15.92 GB
  Browsers:
    Chrome: 127.0.6533.89
    Edge: Chromium (127.0.2651.74)
  npmPackages:
    @rsbuild/core: ^1.0.1-beta.9 => 1.0.1-beta.9
    @rsbuild/plugin-react: ^1.0.1-beta.9 => 1.0.1-beta.9

Details

The builtin:lightningcss-loader ignores layers specified on imports in the root css file.

Index.css

@layer reset, base, components;

@import './a.css' layer(reset);
@import './b.css' layer(base);

Expected Output

@layer reset {
  .a {
    color: red;
  }
}

@layer base {
  .b {
    color: green;
  }
}

@layer components;

Actual Output

.a {
  color: red;
}

.b {
  color: green;
}

@layer reset, base, components;

Reproduce link

https://codesandbox.io/p/devbox/9lyypl?migrateFrom=7rj2zn

Reproduce Steps

  1. Use the builtin:lightningcss-loader in your config
  2. In the root css file import another css file and set a layer for it. - @import './component.css' layer(components)
  3. Run the rsbuild
  4. Check of the components are properly layered in the output css
@chenjiahan chenjiahan transferred this issue from web-infra-dev/rsbuild Aug 5, 2024
@chenjiahan chenjiahan added the bug Something isn't working label Aug 5, 2024
@chenjiahan
Copy link
Member

I think this is an unsupported CSS feature of Rspack and has nothing to do with lightningcss-loader.

  • webpack + css-loader + mini-css-extract-plugin: the generated CSS bundle is as expected.
  • Rspack + css-loader + CssExtractRspackPlugin: the generated CSS bundle is missing layers.

@chenjiahan
Copy link
Member

Maybe related: #5340

@chenjiahan chenjiahan changed the title [Bug]: builtin:lightningcss-loader ignores layers specified on imports in the main css file [Bug]: Rspack ignores layers specified on imports in the main css file Aug 11, 2024
Copy link

stale bot commented Oct 10, 2024

This issue has been automatically marked as stale because it has not had recent activity. If this issue is still affecting you, please leave any comment (for example, "bump"). We are sorry that we haven't been able to prioritize it yet. If you have any new additional information, please include it with your comment!

@chenjiahan
Copy link
Member

Fixed by #7583

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working stale
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants