cssnano / cssnano

A modular minifier, built on top of the PostCSS ecosystem.
https://cssnano.github.io/cssnano/
MIT License
4.78k stars 319 forks source link

Remove `cssnano-preset-default` from `cssnano` #817

Closed Timer closed 4 years ago

Timer commented 5 years ago

It'd be great if either cssnano-preset-default could be removed as a dependency from cssnano or if a second package could be provided that doesn't carry this extremely heavy dependency.

Maybe cssnano-preset-to-plugin or similar (since that's what cssnano really is).

cssnano-preset-default currently weighs in at 10+ MB.

developit commented 5 years ago

Working around this is surprisingly difficult and involves repackaging cssnano.

alexander-akait commented 5 years ago

cssnano without cssnano-preset-default does not have sense, why it is necessary?

Timer commented 5 years ago

So if you're using cssnano with a different present you can avoid downloading the 10+ MB default present.

alexander-akait commented 5 years ago

Can you provide example using cssnano with out plugins?

Timer commented 5 years ago

@evilebottnawi cssnano cannot be used without plugins, as cssnano really only unwraps a preset into multiple plugins, each which perform a minify responsibility.

We're asking for the package that handles this responsibility to be separated for use cases where we don't want to use cssnano-preset-default. Maybe this is better handled in user-land.

alexander-akait commented 5 years ago

hm, maybe we can do this for next major release

/cc @ben-eb

ben-eb commented 5 years ago

Currently there are two presets which we maintain, default and advanced - advanced is really an extension of default, so those using advanced shouldn't care that default is bundled, as they use the same plugins under the hood.

So those are our two main use cases; safe by default, and an opt-in for unsafe transforms. Do we have any other use cases where the list of plugins for default should be changed? As far as I'm aware, the preset system is much less used than something like eslint, so taking out the default preset from this package adds yet more configuration to the tool; I think the majority of our users don't really care about the minutiae of what we do by default as long as it is safe.

Whilst you can compose together a CSS minifier from picking your own PostCSS plugins, there is value in providing "one tool" whereby a user does not need to do that work.

I know cssnano is heavy, that's one of the costs of making modular systems. The benefit is that you can pick transforms piecemeal, whereas a lighter monolith may be much harder to customise. We also rely on work from others, such as the excellent svgo tool. If there are ways you can think of that reduce this tool's size whilst keeping the functionality I'd love to hear them.

alexander-akait commented 4 years ago

Closing due to inactivity. Answer here https://github.com/cssnano/cssnano/issues/817#issuecomment-531906096. We do not plan to change it now, perhaps in the future we will revisit it.