gatsby icon indicating copy to clipboard operation
gatsby copied to clipboard

feat(gatsby): SWC minifier & Lightning CSS

Open LekoArts opened this issue 2 years ago • 1 comments

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]

LekoArts avatar Sep 09 '22 06:09 LekoArts

Marked as draft until we tested this a bit further

LekoArts avatar Sep 13 '22 05:09 LekoArts

Closing for now and will revisit this in the new year

LekoArts avatar Nov 30 '22 09:11 LekoArts