Anidetrix / rollup-plugin-styles

🎨 Universal Rollup plugin for styles: PostCSS, Sass, Less, Stylus and more.
https://anidetrix.github.io/rollup-plugin-styles
MIT License
242 stars 43 forks source link

Unwrapped postcss-nested classes are not exportsd as css-modules #182

Open k-g-a opened 3 years ago

k-g-a commented 3 years ago

Good day! Firts of all, thanks for the great work on this plugin!

I've discovered a wired "bug" using it with postcss-nested plugin. In short, the following style:

// styles.css
.list {
  color: red;

  &_item {
    color: green;
  }
}

Results in:

// some-module.js
import styles from "./styles.css";

console.log(styles.list); // => "styles_list__HASH"
console.log(styles.list_item); // => undefined 

The detailed explanation could be found in the README.md of the postcss-nested-once plugin i've made to overcome the issue. It was intially written for the internal usage, but, as there is a chance it could help someone facing the same issue, I decided to publish.

It would be great if you could mention it somewhere in the docs. Another great option would be if you could reimplement the same approach behind another setting (i.e. nested: boolean | NestedOptions) as it's done for import/url.