parcel-bundler / parcel-bundler/lightningcss

Possible to use nesting as minification feature

Open
#623 4 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

area: minification
Dominant language
Rust
Stars
7.7k
Forks
302
PR merge metrics
No merged PRs in 30d

Description

Is it possible for lightningcss to shorten selectors to use nesting, now with modern browser supporting css nesting?

So for example if the input is

.test .a {
  background: red
}
.test .b {
  background: yellow;
}

I'd want lightningcss to output .test{.a{background:red}.b{background:yellow}}

Reason for that is that SASS isn't going to output native nesting for now: https://sass-lang.com/blog/sass-and-native-nesting/

But I think that by doing so my styles that heavily use sass nesting could be greatly reduced in output size. So if lightningcss could just try to create nesting using some heuristics and use the result if it's smaller that would be greatly appreciated :)

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

No files, tests, or entry points are identified in the issue. Start by locating lightningcss's selector minification and CSS nesting handling, then measure the supplied examples; done means safely emitting native nesting only when the result is smaller and preserving equivalent styles.

Written by the indexing model from the issue text.

Assessment

Tech stack
css, rust
Domain
tooling
Issue type
Feature
Difficulty
5/5
Estimated time
Over a week
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.