-
Notifications
You must be signed in to change notification settings - Fork 104
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
Centralize and Automate Plugin Asset Minification in Webpack #1718
base: trunk
Are you sure you want to change the base?
Centralize and Automate Plugin Asset Minification in Webpack #1718
Conversation
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
Added `noErrorOnMissing` to prevent errors when JavaScript or CSS files are absent for specific plugins.
…plugin-asset-minification
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 If you're merging code through a pull request on GitHub, copy and paste the following into the bottom of the merge commit message.
To understand the WordPress project's expectations around crediting contributors, please review the Contributor Attribution page in the Core Handbook. |
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Looking good to me, but someone who is more experienced with webpack than me should review this.
Co-authored-by: Weston Ruter <westonruter@google.com>
Signed-off-by: Shyamsundar Gadde <shyamsundar.gadde@rtcamp.com>
@@ -16,6 +16,7 @@ on: | |||
- 'tests/multisite.xml' | |||
- 'composer.json' | |||
- 'composer.lock' | |||
- 'webpack.config.js' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The reason for adding this is that unit tests for the plugins can fail if the minified assets aren’t generated. Since Webpack is responsible for generating these assets and copying necessary libraries from node_modules
to the build, it makes sense to include changes to webpack.config.js
as a trigger for the unit tests.
Summary
Fixes #1711
This is also an attempt to improve the solution introduced in #1643 by further streamlining the process of generating minified asset files.
Relevant technical choices
npm run build:plugin:optimization-detective
(or any specific plugin), only assets for that plugin are minified.npm run build-plugins
script, which would otherwise re-minify the same assets multiple times (while the overhead may be minimal, this approach avoids redundancy.)npm run build
is executed, it generates minified versions of assets across all plugins.