title: How to configure cssnano for CSS minification?
body: <p>I am trying to configure <code>cssnano</code> plugin for the <code>postcss-loader</code>, which minifies CSS, very similar, as described <a href="https://www.webfoobar.com/node/109" rel="nofollow noreferrer"><strong>here</strong></a>.</p>
  <p><em>Webpack config:</em></p>
  <pre><code>...
  
    module: {
      rules: [
        {
          test: /\.css$/,
          use: [
            MiniCssExtractPlugin.loader, 
            'css-loader',
            {
              loader: 'postcss-loader',
              options: {
                ident: 'postcss',
                plugins: () =&gt; [
                  cssnano({
                    preset: ['default', {
                      discardComments: {
                        removeAll: true,
                      },
                      // how to find index of all available options?
                    }]
                  })
                ]
              }
            },
            'sass-loader'
          ]
        }
      ]
    },
  
  ...
  </code></pre>
  <p><a href="https://cssnano.co/guides/optimisations" rel="nofollow noreferrer"><strong>Here</strong></a> are listed all the optimisations from cssnano documentation</p>
  <p>And <a href="https://cssnano.co/guides/presets" rel="nofollow noreferrer"><strong>here</strong></a> is an example of how to override a single optimisation <code>discardComments</code> on top of <code>default</code> preset.</p>
  <p>Is it possible to override each optimisation configuration individually, like with <code>discardComments</code>? This could be very handy in creating a separate configurations for dev and production.</p>
  <p>Also, in <a href="https://github.com/danierlr/SO_cssnano_test" rel="nofollow noreferrer"><strong>this repo</strong></a> is an unsuccessful attempt with minimal example and the boilerplate.</p>
  <p><strong>EDIT</strong>: cssnano devs told it is not possible to configure each optimisation individually, instead, it might be possible to use each optimisation plugin separately <a href="https://github.com/cssnano/cssnano/issues/849" rel="nofollow noreferrer">source</a></p>