Cssnano: undefined [postcss-discard-empty]

Created on 20 Jun 2016  路  7Comments  路  Source: cssnano/cssnano

Hey,

so using css with gulp & postcss I always get this "warning":

resources/css/app.css
undefined [postcss-discard-empty]

If I remove cssnano, the message disappears. Am I doing something wrong? Is there any more information I can provide to help solve this issue?

question

All 7 comments

Hello,

I think you are seeing the "status" messages that are being set. We introduced this change here: https://github.com/ben-eb/postcss-discard-empty/commit/c52c3c5e690e3f3dcf543de41e4c204cbb137be4.

My guess is that you have postcss-reporter installed and that is outputting these messages. Note that you can whitelist the plugins that you want to see messages from by using the plugins option.

Two things, however:
1) This particular message is useless. Why would we need a warning to say discard-empty is doing its job? And why not the rest of the plugin chain?
2) We'd want to see important messages from cssnano in postcss-reporter.

  1. I added it because one of our users needed this functionality, so it is not useless. Furthermore it is not a warning, but a _status_ message. Ideally any consumer of these messages should be able to tell this by the fact that each message that is produced does not bear the warning type. As for the rest of the plugins, nobody has offered to contribute code that fulfils this purpose, nor asked for this functionality, so unfortunately it is low on my priority list.
  2. Definitely, and this is an area in which I would like to improve, but as you can appreciate I do this project in my spare time. If you agree & think it'd be worth adding more status messages from plugins then contributions (in the same vein as https://github.com/ben-eb/postcss-discard-empty/pull/9) are most welcome.

I hove nothing against logging messages bot this message is useless just as @mikestopcontinues said.
Ok for this part of message [postcss-discard-empty] I now that something is discarded but what undefined means? What was discarded? What is line number of discarded things? ...

If undefined means that "postcss-discard-empty" plugin is only started but nothing has discarded than this message is ridiculous.

undefined is being returned because the status message that we yield here does not have a message property. Is there any value in adding one, given that these are status messages which are not intended to be reported but consumed by other plugins?

Like I wrote above, you should exclude postcss-discard-empty with the plugins option from postcss-reporter if you don't want to see these messages.

If you using postcss-nesting which will unfortunately output empty rule as depicted here jonathantneal/postcss-nesting#19, then you will probably see this being reported.

To give an explicit example of what was mentioned in an earlier comment:
I managed to suppress those messages by changing my webpack.config.prod.js file's postcss entry from this:


  postcss: () => [
    // ...
    postcssReporter({
      clearMessages: true
    }),
    // ...
  ],

to:


  postcss: () => [
    // ...
    postcssReporter({
      clearMessages: true,
      plugins: ['!postcss-discard-empty']
    }),
    // ...
  ],

I'm not sure if there are any other messages that postcss-discard-empty might emit that I might miss, but it certainly suppresses these ones.

Was this page helpful?
0 / 5 - 0 ratings