rollup-plugin-postcss icon indicating copy to clipboard operation
rollup-plugin-postcss copied to clipboard

Add possibility to pass cssnano options when using extract

Open vladshcherbin opened this issue 5 years ago • 5 comments

Hey,

In cssnano there are presets which can be used - https://cssnano.co/guides/presets.

I wanted to use them and tried the following config, but it didn't work.

postcss({
  extract: true,
  modules: true,
  namedExports: true,
  minimize: {
    preset: ['default', {
      discardComments: {
        removeAll: true
      }
    }]
  }
})

It seems like when extract is true, options are not passed to cssnano. When not extracted, options are passed.

It would be great have this in extract mode too.

rollup - 1.2.2 rollup-plugin-postcss - 2.0.3

vladshcherbin avatar Mar 10 '19 19:03 vladshcherbin

Just my two cents, but I think cssnano should be removed altogether and developers can just add it to their rollup build as needed. It's super simple to add it as a dependency for your project, and then you can use it according to their docs rather than integrating through this module. Further, upgrading cssnano is then separated from this module.

enure avatar Mar 12 '19 19:03 enure

@enure postcss with modules has all class names, used in files. They can be passed to cssnano and unused classes will be removed from extracted css file. I'm not sure if this is possible with a standalone plugin.

vladshcherbin avatar Mar 12 '19 19:03 vladshcherbin

Gotcha, that makes sense.

enure avatar Mar 12 '19 19:03 enure

This is a complete blocker for us right now as we need to extract the css but svgo is trying to compile our already compiled datauri encoded svgs and throwing an error.

rollup - 1.7.0 rollup-plugin-postcss - 2.0.3

alisonailea avatar Mar 20 '19 23:03 alisonailea

This seems to work now? I think this can be closed perhaps?

getup8 avatar Dec 29 '21 05:12 getup8