gatsby
gatsby copied to clipboard
feat(gatsby): SWC minifier & Lightning CSS
Description
This adds a MODERN_MINIFY
flag for Gatsby 5. It adds:
- https://swc.rs/docs/configuration/minification via https://github.com/webpack-contrib/terser-webpack-plugin#swc
- https://lightningcss.dev/ via https://github.com/webpack-contrib/css-minimizer-webpack-plugin#using-custom-minifier-parcelcss
Note:
@parcel/css
was rebranded to Lightning CSS, I opened https://github.com/webpack-contrib/css-minimizer-webpack-plugin/issues/191
Why Gatsby 5 only? Because in companion with https://github.com/gatsbyjs/gatsby/pull/36522 we're dropping more support for older browsers and this change will remove polyfills for old browsers (see e.g. https://swc.rs/docs/configuration/minification#jscminifymangle)
Benchmarks
Haven't done any yet 😬
Dependency Bumps
- Updating
terser-webpack-plugin
minors should be all fine - Updating majors of
css-minimizer-webpack-plugin
were both only Node.js bumps: https://github.com/webpack-contrib/css-minimizer-webpack-plugin/releases/tag/v3.0.0 & https://github.com/webpack-contrib/css-minimizer-webpack-plugin/releases/tag/v4.0.0
Documentation
Afaik we don't have public docs about this. But we'll need to open the umbrella issue at some point and set up the shortlink.
Related Issues
[ch55427]
Marked as draft until we tested this a bit further
Closing for now and will revisit this in the new year