postcss / postcss-nested

PostCSS plugin to unwrap nested rules like how Sass does it.
MIT License
1.15k stars 66 forks source link

Empty output when using with cssnano #111

Open alexa-infra opened 3 years ago

alexa-infra commented 3 years ago

Something goes wrong when using postcss-nested with cssnano in the postcss pipeline.

> cat no-bug.css
#hello {
  &.world {
    background-color: red;
  }
}
> cat no-bug.css | npx postcss -u postcss-nested --no-map | npx postcss -u cssnano --no-map && echo
#hello.world{background-color:red}
> cat no-bug.css | npx postcss -u postcss-nested -u cssnano --no-map && echo
#hello.world{background-color:red}
> cat bug.css
#hello {
  &.world {
    background-color: red;
    .bug {
      background-color: red;
    }
  }
}
> cat bug.css | npx postcss -u postcss-nested --no-map | npx postcss -u cssnano --no-map && echo
#hello.world,#hello.world .bug{background-color:red}
> cat bug.css | npx postcss -u postcss-nested -u cssnano --no-map && echo

Note the last command produces no output, but the previous command works as expected.

To summarize, if I use raw output from postcss-nested and pass it to cssnano, then it works as expected; if I use both postcss-nested with cssnano in the postcss pipeline, then it produces no output from that buggy file.

"cssnano": "^4.1.10",
"postcss": "^8.2.2",
"postcss-nested": "^5.0.3",

Not sure if it's a bug in postcss-nested, but it has appeared after upgrading from postcss-nested 4.1.2 and postcss 7.0.0 (cssnano version hasn't changed)

ai commented 3 years ago

Sorry. I will not have time in a few next weeks. PR is welcome.