postcss-nested

PostCSS plugin to unwrap nested rules like how Sass does it

postcss-nested downloads postcss-nested version postcss-nested license

postcss-nestedSimilar Packages:

Npm Package Weekly Downloads Trend

3 Years
🌟 Show real-time usage chart on postcss-nested's README.md, just copy the code below.
## Usage Trend
[![Usage Trend of postcss-nested](https://npm-compare.com/img/npm-trend/THREE_YEARS/postcss-nested.png)](https://npm-compare.com/postcss-nested#timeRange=THREE_YEARS)

Cumulative GitHub Star Trend

🌟 Show GitHub stars trend chart on postcss-nested's README.md, just copy the code below.
## GitHub Stars Trend
[![GitHub Stars Trend of postcss-nested](https://npm-compare.com/img/github-trend/postcss-nested.png)](https://npm-compare.com/postcss-nested)

Stat Detail

Package
Downloads
Stars
Size
Issues
Publish
License
postcss-nested01,19917.5 kB417 days agoMIT

README for postcss-nested

PostCSS Nested

PostCSS plugin to unwrap nested rules closer to Sass syntax.

.phone {
  &_title {
    width: 500px;
    @media (max-width: 500px) {
      width: auto;
    }
    body.is_dark & {
      color: white;
    }
  }
  img {
    display: block;
  }
}

.title {
  font-size: var(--font);

  @at-root html {
    --font: 16px;
  }
}

will be processed to:

.phone_title {
  width: 500px;
}
@media (max-width: 500px) {
  .phone_title {
    width: auto;
  }
}
body.is_dark .phone_title {
  color: white;
}
.phone img {
  display: block;
}

.title {
  font-size: var(--font);
}
html {
  --font: 16px;
}

Related plugins:

  • Use postcss-current-selector after this plugin if you want to use current selector in properties or variables values.
  • Use postcss-nested-ancestors before this plugin if you want to reference any ancestor element directly in your selectors with ^&.

Alternatives:


  PostCSS Nested is built by Evil Martians, an American design and engineering consultancy for developer tools, AI, and cybersecurity startups.


Docs

Read full docs here.