postcss-nested icon indicating copy to clipboard operation
postcss-nested copied to clipboard

Empty output when using with cssnano

Open alexa-infra opened this issue 4 years ago • 1 comments

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)

alexa-infra avatar Jan 06 '21 11:01 alexa-infra

Interesting idea.

I do not have time for it but will accept PR.

ai avatar Dec 19 '21 15:12 ai