Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Scripts: Import CSS files before optimization #61121

Merged
merged 2 commits into from
Aug 31, 2024

Conversation

benoitchantre
Copy link
Contributor

What?

Import CSS files before the minification process.

Closes #61112.

Why?

Small performance improvement for people using CSS imports and the @wordpress/scripts package.

How?

postcss-import is run before cssnano

Testing Instructions

  1. Scaffold a block
  2. Rename your main stylesheet from .scss to .css
  3. Create 2 CSS files
  4. Import these files in the main stylesheet
  5. Run npm run build
  6. See that you have a resulting stylesheet that is minified (only one line instead of two)

Testing Instructions for Keyboard

Screenshots or screencast

Copy link

github-actions bot commented Apr 25, 2024

The following accounts have interacted with this PR and/or linked issues. I will continue to update these lists as activity occurs. You can also manually ask me to refresh this list by adding the props-bot label.

If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.

Co-authored-by: benoitchantre <benoitchantre@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>

To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook.

@gziolo gziolo added [Package] Scripts /packages/scripts [Type] Enhancement A suggestion for improvement. labels May 6, 2024
@benoitchantre
Copy link
Contributor Author

@gziolo A few tests have failed at npm install. Should I rebase and force push this PR?

Would you have some time to review it?

Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

It works as advertised in my testing. It will need a rebase to resolve conflicts with the latest changes in trunk.

It would be also nice to add an entry in the changelog file under ## Unreleased section:

### Enhancements

- Inlines CSS files imported from other CSS files before optimization in the `build` command ([#61121](https://github.com/WordPress/gutenberg/pull/61121)).

packages/scripts/package.json Outdated Show resolved Hide resolved
@gziolo gziolo changed the title Import CSS files before optimization Scripts: Import CSS files before optimization Aug 30, 2024
Copy link
Member

@gziolo gziolo left a comment

Choose a reason for hiding this comment

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

Thank you so much for taking it to the finish line.

@gziolo gziolo enabled auto-merge (squash) August 31, 2024 06:29
@gziolo gziolo merged commit 5a15320 into WordPress:trunk Aug 31, 2024
61 checks passed
@github-actions github-actions bot added this to the Gutenberg 19.2 milestone Aug 31, 2024
bph pushed a commit to bph/gutenberg that referenced this pull request Aug 31, 2024
* Import CSS files before optimization

Closes WordPress#61112.

* Update changelog

Co-authored-by: benoitchantre <benoitchantre@git.wordpress.org>
Co-authored-by: gziolo <gziolo@git.wordpress.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[Package] Scripts /packages/scripts [Type] Enhancement A suggestion for improvement.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

wp-scripts: minification of CSS imports is done too early in the process
2 participants