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

Stop working when contains @layer declaration #1272

Open
otomad opened this issue Mar 12, 2024 · 3 comments
Open

Stop working when contains @layer declaration #1272

otomad opened this issue Mar 12, 2024 · 3 comments

Comments

@otomad
Copy link

otomad commented Mar 12, 2024

IMPORTANT: clean-css is now in a maintenance mode. PRs are still welcome, and I will try do an occasional bugfix relase.

Precheck

  • Do a quick search and make sure a bug has not yet been reported;
  • do a quick check if the bug still exists in the latest patch version;
  • finally, be nice and have fun!

Environment

  • clean-css version - npm ls clean-css: 5.3.3
  • node.js version - node -v: v20.6.1
  • operating system: Windows 11 23H2 22631.2861

Configuration options

const CleanCSS = (await import("clean-css")).default;
new CleanCSS({});

Input CSS

@layer theme, layout, utilities;

Example from https://developer.mozilla.org/en-US/docs/Web/CSS/@layer

Actual output CSS

Nothing. And even ignore the following CSS rules.

Warning

Invalid character(s) 'utilities;' at 1:22. Ignoring.

Expected output CSS

@layer theme,layout,utilities;
@otomad otomad changed the title Support @layer declaration Stop working when contains @layer declaration Mar 12, 2024
@kerryj89
Copy link

kerryj89 commented Apr 6, 2024

Ran into this problem also, @layer declaration gets removed but the @layer {} nesting remains. I changed to cssnano for now. Side note: cssnano doubles the time it takes to process my css compared to clean-css.

@otomad
Copy link
Author

otomad commented May 4, 2024

Ran into this problem also, @layer declaration gets removed but the @layer {} nesting remains. I changed to cssnano for now. Side note: cssnano doubles the time it takes to process my css compared to clean-css.

Suggest to use lightningcss. cssnano can accept @layer declaration but just ignore it, and lightningcss can even remove the spaces after the commas from the @layer declaration.

@daniele-orlando
Copy link

Same issue here where valid layer code gets removed from output.

<style>
@layer reset, libs, app;
</style>

outputs to

<style>
</style>

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