Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
18 commits
Select commit Hold shift + click to select a range
4d543ef
Add CSS minification for Twenty Twenty-Two and Twenty Twenty-Five themes
b1ink0 Sep 25, 2025
d3beb63
Add CSS minification for Twenty Nineteen, Twenty Twenty, and Twenty T…
b1ink0 Sep 29, 2025
96cc018
Add re-minification instructions notice to the Twenty Nineteen, Twent…
b1ink0 Sep 29, 2025
d2a352b
Revert "Add re-minification instructions notice to the Twenty Ninetee…
b1ink0 Sep 30, 2025
0e2085e
Revert "Add CSS minification for Twenty Nineteen, Twenty Twenty, and …
b1ink0 Sep 30, 2025
d479361
Improve documentation
b1ink0 Sep 30, 2025
0f0df2f
Simplify stylesheet filename logic using `SCRIPT_DEBUG` suffix
b1ink0 Sep 30, 2025
2a1d893
Merge branch 'trunk' of https://github.com/WordPress/wordpress-develo…
westonruter Oct 6, 2025
f908cca
Add twentytwentytwo and twentytwentyfive to test-and-zip-default-them…
westonruter Oct 6, 2025
b83b6d0
Add dependabot configs for the themes
westonruter Oct 6, 2025
3a9539d
Improve notice in style.css regarding minification process
westonruter Oct 6, 2025
b43e826
Fix typo
westonruter Oct 6, 2025
ff55cb6
Add TT2 and TT5 themes to workflow triggers
b1ink0 Oct 7, 2025
8ceb867
Simplify notice in `style.css` for Twenty Twenty-Two and Twenty Twent…
b1ink0 Oct 7, 2025
a9e839c
Add contributing.txt files for npm usage
westonruter Oct 7, 2025
39bac29
Add steps to bundle-theme to minify CSS for twentytwentytwo and twent…
westonruter Oct 8, 2025
5c09f2e
Merge branch 'trunk' into feature/add-stylesheet-minification-for-bun…
westonruter Oct 12, 2025
99a0969
Avoid including node_modules in theme release ZIP
westonruter Oct 12, 2025
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 22 additions & 0 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -129,6 +129,28 @@ updates:
- "underscore"

# Monitor npm dependencies within default themes.
- package-ecosystem: "npm"
directory: "/src/wp-content/themes/twentytwentyfive"
schedule:
interval: "weekly"
open-pull-requests-limit: 20
groups:
twentytwentyfive-css:
patterns:
- "**browserslist*"
- "*css*"

- package-ecosystem: "npm"
directory: "/src/wp-content/themes/twentytwentytwo"
schedule:
interval: "weekly"
open-pull-requests-limit: 20
groups:
twentytwentytwo-css:
patterns:
- "**browserslist*"
- "*css*"

- package-ecosystem: "npm"
directory: "/src/wp-content/themes/twentytwentyone"
schedule:
Expand Down
28 changes: 27 additions & 1 deletion .github/workflows/test-and-zip-default-themes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,8 @@ on:
- 'src/wp-content/themes/twentynineteen/**'
- 'src/wp-content/themes/twentytwenty/**'
- 'src/wp-content/themes/twentytwentyone/**'
- 'src/wp-content/themes/twentytwentytwo/**'
- 'src/wp-content/themes/twentytwentyfive/**'
# Changes to this workflow file should always verify success.
- '.github/workflows/test-and-zip-default-themes.yml'
pull_request:
Expand All @@ -29,6 +31,8 @@ on:
- 'src/wp-content/themes/twentynineteen/**'
- 'src/wp-content/themes/twentytwenty/**'
- 'src/wp-content/themes/twentytwentyone/**'
- 'src/wp-content/themes/twentytwentytwo/**'
- 'src/wp-content/themes/twentytwentyfive/**'
# Changes to this workflow file should always verify success.
- '.github/workflows/test-and-zip-default-themes.yml'
workflow_dispatch:
Expand Down Expand Up @@ -120,6 +124,8 @@ jobs:
fail-fast: false
matrix:
theme: [
'twentytwentyfive',
'twentytwentytwo',
'twentytwentyone',
'twentytwenty',
'twentynineteen',
Expand Down Expand Up @@ -221,11 +227,31 @@ jobs:
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false

- name: Set up Node.js for themes needing minification
if: matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive'
uses: actions/setup-node@49933ea5288caeca8642d1e84afbd3f7d6820020 # v4.4.0
with:
node-version-file: '.nvmrc'
cache: npm
cache-dependency-path: src/wp-content/themes/${{ matrix.theme }}/package-lock.json

- name: Install npm dependencies
if: matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive'
run: npm ci
working-directory: src/wp-content/themes/${{ matrix.theme }}

- name: Build theme assets
if: matrix.theme == 'twentytwentytwo' || matrix.theme == 'twentytwentyfive'
run: npm run build
working-directory: src/wp-content/themes/${{ matrix.theme }}

- name: Upload theme ZIP as an artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ matrix.theme }}
path: src/wp-content/themes/${{ matrix.theme }}
path: |
src/wp-content/themes/${{ matrix.theme }}
!src/wp-content/themes/${{ matrix.theme }}/node_modules
if-no-files-found: error
include-hidden-files: true

Expand Down
6 changes: 6 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -88,6 +88,12 @@ wp-tests-config.php
/src/wp-content/themes/twentynineteen/node_modules
/src/wp-content/themes/twentytwentyone/node_modules
/src/wp-content/themes/twentytwenty/node_modules
/src/wp-content/themes/twentytwentytwo/node_modules
/src/wp-content/themes/twentytwentyfive/node_modules

# Minified files in bundled themes
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this will have the effect of never shipping the minified files since the files won't be in the checked out code.

Copy link
Author

@b1ink0 b1ink0 Oct 7, 2025

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, since the minified files are ignored, the ZIP files are being prepared from the repository without the minified files. See below:

steps:
- name: Checkout repository
uses: actions/checkout@08c6903cd8c0fde910a37f88322edcfb5dd907a8 # v5.0.0
with:
ref: ${{ github.event_name == 'workflow_dispatch' && inputs.branch || github.ref }}
show-progress: ${{ runner.debug == '1' && 'true' || 'false' }}
persist-credentials: false
- name: Upload theme ZIP as an artifact
uses: actions/upload-artifact@ea165f8d65b6e75b540449e92b4886f43607fa02 # v4.6.2
with:
name: ${{ matrix.theme }}
path: src/wp-content/themes/${{ matrix.theme }}
if-no-files-found: error
include-hidden-files: true

There are two options I can think of to resolve this:

  1. We can include the minified files in the repo, similar to how classic themes require contributors to include the built CSS and CSS map files generated from SCSS files.

  2. We could add a build step for TT2 and TT5 in the workflow for the bundle-theme job before the Upload theme ZIP as an artifact step is run.
    This would work if the release of the bundled theme is handled through a GitHub workflow.
    ref: https://make.wordpress.org/core/handbook/about/release-cycle/update-bundled-themes-2/#creating-theme-zip-files

cc: @westonruter

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It sounds like the second option would be preferred, as I really don't like minified files being committed to the repo. For the classic themes using SASS it's a bit different because the changes to the .scss files at least result in changes to .css files which can get a clean diff. But for minified files, and changes just results in a lot of noise.

I will admit I don't have any experience with the theme release workflows, so I don't know specifically what is required to implement that second option.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I drafted the new bundle-theme job steps with assistance from Gemini Code Assist: 39bac29

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Props to @sabernhardt for pointing out that the node_modules was getting included in the build artifacts! This should now be removed as of 99a0969.

/src/wp-content/themes/twentytwentytwo/*.min.css
/src/wp-content/themes/twentytwentyfive/*.min.css

# Operating system specific files
.DS_Store
Expand Down
11 changes: 11 additions & 0 deletions Gruntfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,16 @@ module.exports = function(grunt) {
src: [
'wp-admin/css/colors/*/*.css'
]
},
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

None of the other default themes are included. Is there a reason to only include these two?

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes, in this PR only TT2 and TT5 have their stylesheets minified, other themes with a build step do not minify their stylesheets.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The idea is to start out with just minding the stylesheets for block themes since they are small and eligible to be inlined. Once we have a good workflow in place for block themes, we can follow up with minification for classic themes. However the performance gains won't be as large because the larger stylesheets wouldn't be eligible for inlining. A reduced size for an external stylesheet doesn't translate into as much of a performance boost as being able to eliminate that render blocking stylesheet in the first place, as I understand.

themes: {
expand: true,
cwd: WORKING_DIR,
dest: WORKING_DIR,
ext: '.min.css',
src: [
'wp-content/themes/twentytwentytwo/style.css',
'wp-content/themes/twentytwentyfive/style.css',
]
}
},
rtlcss: {
Expand Down Expand Up @@ -1591,6 +1601,7 @@ module.exports = function(grunt) {
'rtl',
'cssmin:rtl',
'cssmin:colors',
'cssmin:themes',
'usebanner'
] );

Expand Down
19 changes: 19 additions & 0 deletions src/wp-content/themes/twentytwentyfive/contributing.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
=== Contributing to Twenty Twenty-Five ===

= Minifying CSS =

Twenty Twenty-Five has a single stylesheet `style.css` which is enqueued in addition to the global styles coming from core. On a normal production site, when `SCRIPT_DEBUG` is disabled, then the minified version `style.min.css` will be enqueued instead. If you make a change to `style.css`, you'll need to re-minify the `style.min.css` using the built-in npm build tool. As always, it is preferable to use the Site Editor to supply Additional CSS instead of directly editing the theme stylesheet.

Installation instructions

1. Using a command line interface, go to the “twentytwentyfive” directory `cd /my-computer/local-wordpress-install/src/wp-content/themes/twentytwentyfive`.

2. Type `npm install` into the command line, and press the [return] key, to install all Node.js dependencies.

3. The dependencies may take a few minutes to download but once it completes, you’re done.

Usage instructions

1. After making a change to the `style.css` file, run `npm run build` from within the theme directory to regenerate `style.min.css` with your new changes.

2. You can also “watch” the theme directory for CSS changes and re-minify the CSS anytime a change occurs by running: `npm run watch`.
9 changes: 6 additions & 3 deletions src/wp-content/themes/twentytwentyfive/functions.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,19 +39,22 @@ function twentytwentyfive_editor_style() {
endif;
add_action( 'after_setup_theme', 'twentytwentyfive_editor_style' );

// Enqueues style.css on the front.
// Enqueues the theme stylesheet on the front.
if ( ! function_exists( 'twentytwentyfive_enqueue_styles' ) ) :
/**
* Enqueues style.css on the front.
* Enqueues the theme stylesheet on the front.
*
* @since Twenty Twenty-Five 1.0
*
* @return void
*/
function twentytwentyfive_enqueue_styles() {
$suffix = SCRIPT_DEBUG ? '' : '.min';
$src = 'style' . $suffix . '.css';

wp_enqueue_style(
'twentytwentyfive-style',
get_parent_theme_file_uri( 'style.css' ),
get_parent_theme_file_uri( $src ),
array(),
wp_get_theme()->get( 'Version' )
);
Expand Down
Loading
Loading