Bundled Themes: Introduce stylesheet minification for core block themes.
This introduces a build process to provide minified stylesheets for the Twenty Twenty-Two and Twenty Twenty-Five themes. The built minified CSS is not committed to version control. When SCRIPT_DEBUG is disabled, the minified style.min.css file will be enqueued to improve performance, including reducing render-blocking resources as well as facilitating inlining. See #63007.
- Stylesheets are minified via the new core
cssmin:themes Grunt task, which is automatically run as part of build:css.
- The same build process is added to the themes (via
package.json and package-lock.json) with build and watch commands; the postcss and cssnano development dependencies are used to handle CSS minification.
- The
functions.php in each theme is updated to enqueue style.min.css unless SCRIPT_DEBUG is enabled, in which case style.css is enqueued.
- A notice comment is added to
style.css to warn against editing the stylesheet since the minified version will likely be served instead.
- A new
contributing.txt file is added to each theme to document the build process for developers.
- The
test-and-zip-default-themes GitHub workflow is updated to install npm dependencies and build the minified assets before packaging the themes.
- New PHPUnit tests are added to verify version number consistency across
style.css, readme.txt, package.json, and package-lock.json files in default themes.
Developed in https://github.com/WordPress/wordpress-develop/pull/10081.
Props b1ink0, westonruter, shyamgadde, jonsurrell, sabernhardt, jorbin, peterwilsoncc, poena.
Fixes #63012.