Skip to content

Scripts: Webpack config update to minimize CSS - #33676

Merged
gziolo merged 3 commits into
WordPress:trunkfrom
christianztamayo:fix/build-minify-css
Jul 28, 2021
Merged

Scripts: Webpack config update to minimize CSS#33676
gziolo merged 3 commits into
WordPress:trunkfrom
christianztamayo:fix/build-minify-css

Conversation

@christianztamayo

Copy link
Copy Markdown
Contributor

Description

The previous configuration does not have CSS minification included aside from the sass-loader built-in which only affects SCSS files. (Closes #33643, Related: #29624)

How has this been tested?

Types of changes

Added the optimize-css-assets-webpack-plugin to the minimizer config.

Checklist:

  • My code is tested.
  • My code follows the WordPress code style.
  • [-] My code follows the accessibility standards.
  • [-] I've tested my changes with keyboard and screen readers.
  • [-] My code has proper inline documentation.
  • [-] I've included developer documentation if appropriate.
  • [-] I've updated all React Native files affected by any refactorings/renamings in this PR (please manually search all *.native.js files for terms that need renaming or removal).

@github-actions github-actions Bot added the First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository label Jul 25, 2021
@github-actions

Copy link
Copy Markdown

👋 Thanks for your first Pull Request and for helping build the future of Gutenberg and WordPress, @christianztamayo! In case you missed it, we'd love to have you join us in our Slack community, where we hold regularly weekly meetings open to anyone to coordinate with each other.

If you want to learn more about WordPress development in general, check out the Core Handbook full of helpful information.

Comment thread packages/scripts/package.json Outdated
@gziolo gziolo added [Tool] WP Scripts /packages/scripts [Type] Enhancement A suggestion for improvement. labels Jul 27, 2021
Comment thread packages/scripts/config/webpack.config.js Outdated
christianztamayo and others added 2 commits July 27, 2021 23:20
Adds the optimize-css-assets-webpack-plugin to the minimizer config
Comment thread packages/scripts/config/webpack.config.js Outdated

@gziolo gziolo left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

I tested this PR and it works as advertised. Thank you for the improvement 👍🏻

@gziolo
gziolo merged commit 21e78ef into WordPress:trunk Jul 28, 2021
@github-actions

Copy link
Copy Markdown

Congratulations on your first merged pull request, @christianztamayo! We'd like to credit you for your contribution in the post announcing the next WordPress release, but we can't find a WordPress.org profile associated with your GitHub account. When you have a moment, visit the following URL and click "link your GitHub account" under "GitHub Username" to link your accounts:

https://profiles.wordpress.org/me/profile/edit/

And if you don't have a WordPress.org account, you can create one on this page:

https://login.wordpress.org/register

Kudos!

@github-actions github-actions Bot added this to the Gutenberg 11.3 milestone Jul 28, 2021
@ocean90

ocean90 commented Jul 28, 2021

Copy link
Copy Markdown
Member

@gziolo This should probably be released as a breaking change because it can impact users which have their own PostCSS config which already includes cssnano (which optimize-css-assets-webpack-plugin uses by default) with a custom config for allowed optimisations.

Since sass-loader seems to minify the CSS already, should we maybe extend the default PostCSS config to use cssnano instead?

Related:

@gziolo

gziolo commented Jul 28, 2021

Copy link
Copy Markdown
Member

@ocean90, if we can avoid all the hassle by extending the default PostCSS config then it would be the best solution. Let's explore that approach. We have some time (2 weeks) because the new Gutenberg plugin was cut before I merged these changes 😄

@gziolo

gziolo commented Jul 29, 2021

Copy link
Copy Markdown
Member

I opened a follow-up: #33750.

sirreal added a commit that referenced this pull request Aug 13, 2026
The 17.1.0 backport silently included #33676 after publication, and its #33750 replacement followed the stale heading. Neither implementation shipped before 18.0.0.

Evidence: git diff 4e106dd f0b55c2 -- 'packages/*/CHANGELOG.md'
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

First-time Contributor Pull request opened by a first-time contributor to Gutenberg repository [Tool] WP Scripts /packages/scripts [Type] Enhancement A suggestion for improvement.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Scripts: The build command does not minify CSS files

4 participants