marp-team / marp-core

The core of Marp converter
MIT License
766 stars 129 forks source link

Use simpler CSS minify for runtime #381

Closed yhatt closed 2 weeks ago

yhatt commented 2 weeks ago

314 has been pointed out that CSS minifier plugins are depending on the limited context (Node.js). I've been resolved by prebundling critical plugins in #315, but we still received that Marp Core is still incompatible in some JavaScript environments such as Cloudflare Workers, because the prebundled script is still depending on path and utils.

An community fork @syumai/marp-core for making compatible Marp Core with Cloudflare Workers is actually removing CSS minification. https://github.com/syumai/marp-core/pull/1/commits/cc24fcb211ac7e98db5dd815ba0ebcba6271c3e9

For getting rid off Node.js dependency in minifyCSS feature, this PR will replace PostCSS plugin for minify from cssnano plugins into simpler plugin @csstools/postcss-minify. That makes no longer depended on Node.js packages, and no longer required complex prebundling settings. 🙌

Instead, cssMinify will no longer apply minification to CSS selectors and declarations. That is major change, but we do not think that is having major impact because this plugin has consistent gurantees:

It guarantees two things :

  • browsers can not tell the difference between the original and the minified CSS
  • lawyers can not tell the difference between the original and the minified CSS

https://github.com/csstools/postcss-plugins/tree/main/plugins/postcss-minify#readme